This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.