WM: improve timer precision for more precise playback #111603
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111603
Loading…
Reference in New Issue
No description provided.
Delete Branch "ideasman42/blender:pr-high-precision-timers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a timer needs to execute during the idle time (currently 5ms),
use microsecond precision to ensure the timer isn't delayed by the idle
time.
This improves the precision of animation playback on systems that support it
(WIN32, see note below).
In my tests FPS playback varied:
Using higher precision timers mostly resolves this issue although there
is still some jitter although it's now limited to ~0.01 FPS.
These values were measured with the FPS samples set to show real times
between frames (without them being smoothed out).
This is a continuation of a fix for #111579 which avoided the worst of the jittering issues at higher frame rates.
It appears WIN32 doesn't support sleeping shorter than 1 millisecond via
std::this_thread::sleep_for
, making this change have no benefit on WIN32, from tests it also doesn't have any down sides, so avoid platform specific logic. The WIN32 limitation is noted in code-comments. If a method of higher precision method is available this can be investigated.To reproduce this error, set the FPS samples preference to 1, use the default scene and play animation either at 59.94 or 23.98 FPS.
Using a fractional FPS ensures a fractional FPS is displayed in the view-port.
NOTES:
std::this_thread::sleep_for
is implemented internally on Windows. It may be that the C++ implementation has down-sides similar to the kinds of workarounds I found online (when looking into implementing a microsecond version ofPIL_sleep_ms
on WIN32).@blender-bot build
From code PoV, LGTM.
Have you tried it on a Windows machine? According to this thread e.g., it seems that Windows can have fairly longer times than requested with this call, wondering if it does stabilize the FPS on this OS?
@blender-bot package windows
Package build started. Download here when ready.
@mont29 no, I haven't tested on windows (set the build-bot to create a package).
It seems that this may not work well on windows - or may have higher CPU use.
We could either:
Testing on windows
std::this_thread::sleep_for
doesn't have any noticable advantage overPIL_sleep_ms
comparing before/after side-by-side the frame-jitter - the problem was exactly the same.For reference this was a low end laptop with a built in intel GPU, tested with small windows with a blank view-port:
Made a test commit to check on spinning until sub 1ms timers are reached, I'm not especially keen on this but if the overall CPU usage isn't much higher it might be OK.
Update: this doesn't make any noticeable improvement either (nor does in result in noticeably higher CPU usage).
@blender-bot package windows
Package build started. Download here when ready.
f0f9364f74
to74d0bb2e81
74d0bb2e81
to6d2ea5435a
6d2ea5435a
to04dd7606db
Updated the PR to remove WIN32 ifdef's & the PR message to note that this change doesn't show noticeable improvements on WIN32.
While I'm less keen on this change given it doesn't solve timer precision on WIN32, it's also not great to limit macOS & Linux because of a limitation on WIN32.
We could also define this problem as a technical limitation that doesn't actually impact users, if the FPS playback is good enough from what the user can perceive, the fact the FPS display jitters, could be overlooked.
If others feel positively about this change I think it's OK to include but we could leave it as a known limitation too.
I think it's fine to improve Linux/OSX, even if Windows cannot benefit from this, the changes are not that big, and in the future maybe the windows
std
implementation will be better?Could be worth keeping a task somewhere though about improving our timer precision on Windows.