Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

vsync issue work-around #197

Closed
wants to merge 2 commits into from
Closed

vsync issue work-around #197

wants to merge 2 commits into from

Conversation

zhuxingwei
Copy link
Contributor

@zhuxingwei zhuxingwei commented Jul 12, 2021

This PR fixes two issues:
(1) UIWidgetsSystem::Wait is triggered after WaitForTargetFPS call in Unity (If the current frame cost N ms, the WaitForTargetFPS will stop the main thread for 16-N ms) where we will call Update() and trigger costly "drawFrame" callbacks in the ui thread task pool. As the result, the frame rate will drop since the wait time is wrong (The wait time should be 16 - N - cost-of-UIWidgetsSystem::Wait, instead of 16 - N). Current solution is to remove Update() from it.

(2) In our code we hard-coded the interval between each two VSyncs as 1/60 s. However, currently this is not true (the internval of two VSyncs depends on the "Wait" duration of the previous frame and the "Update" duration of the following frame, which is not guaranteed to be 1/60 s at any time), therefore the UI animation is not fluent. Current solution is to move VSync calls to the end of each frame (i.e., inside the UIWidgetsSystem::Wait function) so the animation will be fluent if the PFS is 60.

IMPORTANT: this PR is only a temporary work-around. We should eventually fix this issue on the Unity Engine side.

@zhuxingwei zhuxingwei changed the title vsync issue [WIP] vsync issue Jul 12, 2021
@zhuxingwei zhuxingwei changed the title [WIP] vsync issue vsync issue work-around Jul 13, 2021
@zhuxingwei
Copy link
Contributor Author

already included in #226

@zhuxingwei zhuxingwei closed this Aug 11, 2021
@zhuxingwei zhuxingwei deleted the vsync_issue_fix branch November 24, 2021 08:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant