From 8b04f3c7cca787d0bd045e2fb10443a10ed83857 Mon Sep 17 00:00:00 2001 From: Xingwei Zhu Date: Mon, 12 Jul 2021 17:56:27 +0800 Subject: [PATCH 1/2] vsync issue --- .../unity/android/uiwidgets_system.cc | 19 +++++--------- .../unity/darwin/ios/uiwidgets_system.mm | 25 +++++++------------ .../unity/darwin/macos/uiwidgets_system.mm | 25 +++++++------------ .../unity/windows/uiwidgets_system.cc | 21 ++++++++++------ 4 files changed, 37 insertions(+), 53 deletions(-) diff --git a/engine/src/shell/platform/unity/android/uiwidgets_system.cc b/engine/src/shell/platform/unity/android/uiwidgets_system.cc index 8c5fc64ad..37a700210 100644 --- a/engine/src/shell/platform/unity/android/uiwidgets_system.cc +++ b/engine/src/shell/platform/unity/android/uiwidgets_system.cc @@ -21,16 +21,11 @@ void UIWidgetsSystem::UnregisterPanel(UIWidgetsPanel* panel) { } void UIWidgetsSystem::Wait(std::chrono::nanoseconds max_duration) { - Update(); - - std::chrono::nanoseconds wait_duration = - std::max(std::chrono::nanoseconds(0), - next_uiwidgets_event_time_ - TimePoint::clock::now()); - - wait_duration = std::min(max_duration, wait_duration); - - //TODO: find a proper api similar to MsgWaitForMultipleObjects on Windows - // which will notify os to wait for the given period of time + //TODO zxw: Rename this function to VSync, should be done after Engine side changes land + //Process VSync at the end of this frame + for (auto* uiwidgets_panel : uiwidgets_panels_) { + uiwidgets_panel->ProcessVSync(); + } } void UIWidgetsSystem::Update() { @@ -46,9 +41,7 @@ void UIWidgetsSystem::Update() { } void UIWidgetsSystem::VSync() { - for (auto* uiwidgets_panel : uiwidgets_panels_) { - uiwidgets_panel->ProcessVSync(); - } + //TODO zxw: Remove this function, should be done after Engine side changes land } void UIWidgetsSystem::WakeUp() {} diff --git a/engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm b/engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm index ea33f6146..72261fd5a 100644 --- a/engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm +++ b/engine/src/shell/platform/unity/darwin/ios/uiwidgets_system.mm @@ -21,16 +21,14 @@ } void UIWidgetsSystem::Wait(std::chrono::nanoseconds max_duration) { - Update(); - - std::chrono::nanoseconds wait_duration = - std::max(std::chrono::nanoseconds(0), - next_uiwidgets_event_time_ - TimePoint::clock::now()); - - wait_duration = std::min(max_duration, wait_duration); - - //TODO: find a proper api similar to MsgWaitForMultipleObjects on Windows - // which will notify os to wait for the given period of time + //TODO zxw: Rename this function to VSync, should be done after Engine side changes land + //Process VSync at the end of this frame + for (auto* uiwidgets_panel : uiwidgets_panels_) { + if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { + continue; + } + uiwidgets_panel->ProcessVSync(); + } } void UIWidgetsSystem::Update() { @@ -49,12 +47,7 @@ } void UIWidgetsSystem::VSync() { - for (auto* uiwidgets_panel : uiwidgets_panels_) { - if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { - continue; - } - uiwidgets_panel->ProcessVSync(); - } + //TODO zxw: Remove this function, should be done after Engine side changes land } void UIWidgetsSystem::WakeUp() {} diff --git a/engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm b/engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm index ea33f6146..72261fd5a 100644 --- a/engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm +++ b/engine/src/shell/platform/unity/darwin/macos/uiwidgets_system.mm @@ -21,16 +21,14 @@ } void UIWidgetsSystem::Wait(std::chrono::nanoseconds max_duration) { - Update(); - - std::chrono::nanoseconds wait_duration = - std::max(std::chrono::nanoseconds(0), - next_uiwidgets_event_time_ - TimePoint::clock::now()); - - wait_duration = std::min(max_duration, wait_duration); - - //TODO: find a proper api similar to MsgWaitForMultipleObjects on Windows - // which will notify os to wait for the given period of time + //TODO zxw: Rename this function to VSync, should be done after Engine side changes land + //Process VSync at the end of this frame + for (auto* uiwidgets_panel : uiwidgets_panels_) { + if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { + continue; + } + uiwidgets_panel->ProcessVSync(); + } } void UIWidgetsSystem::Update() { @@ -49,12 +47,7 @@ } void UIWidgetsSystem::VSync() { - for (auto* uiwidgets_panel : uiwidgets_panels_) { - if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { - continue; - } - uiwidgets_panel->ProcessVSync(); - } + //TODO zxw: Remove this function, should be done after Engine side changes land } void UIWidgetsSystem::WakeUp() {} diff --git a/engine/src/shell/platform/unity/windows/uiwidgets_system.cc b/engine/src/shell/platform/unity/windows/uiwidgets_system.cc index ca588499e..4bcdc73af 100644 --- a/engine/src/shell/platform/unity/windows/uiwidgets_system.cc +++ b/engine/src/shell/platform/unity/windows/uiwidgets_system.cc @@ -21,7 +21,17 @@ void UIWidgetsSystem::UnregisterPanel(UIWidgetsPanel* panel) { } void UIWidgetsSystem::Wait(std::chrono::nanoseconds max_duration) { - Update(); + //TODO zxw: Rename this function to VSync, should be done after Engine side changes land + //Process VSync at the end of this frame + for (auto* uiwidgets_panel : uiwidgets_panels_) { + if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { + continue; + } + uiwidgets_panel->ProcessVSync(); + } + + //TODO zxw: Move this function to a better place + /*Update(); std::chrono::nanoseconds wait_duration = std::max(std::chrono::nanoseconds(0), @@ -32,7 +42,7 @@ void UIWidgetsSystem::Wait(std::chrono::nanoseconds max_duration) { ::MsgWaitForMultipleObjects(0, nullptr, FALSE, static_cast(wait_duration.count() / 1000000), - QS_ALLINPUT); + QS_ALLINPUT);*/ } void UIWidgetsSystem::Update() { @@ -51,12 +61,7 @@ void UIWidgetsSystem::Update() { } void UIWidgetsSystem::VSync() { - for (auto* uiwidgets_panel : uiwidgets_panels_) { - if (!uiwidgets_panel->NeedUpdateByPlayerLoop()) { - continue; - } - uiwidgets_panel->ProcessVSync(); - } + //TODO zxw: Remove this function, should be done after Engine side changes land } void UIWidgetsSystem::WakeUp() {} From 00226818b3070e5f37b2e92dc0713e0e760e6a64 Mon Sep 17 00:00:00 2001 From: Xingwei Zhu Date: Tue, 13 Jul 2021 10:01:23 +0800 Subject: [PATCH 2/2] upload library --- com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so | 4 ++-- com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a | 4 ++-- com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so b/com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so index 14369f9bc..2b70582e2 100755 --- a/com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so +++ b/com.unity.uiwidgets/Runtime/Plugins/Android/libUIWidgets.so @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39792c1a15937910cf2938e3e9937422e3520dab4a14b09f3e8fbf91a233db52 -size 76747900 +oid sha256:a3210034835bd953a1ff906fffc465f41eed383d3084291ffcc3104b2dd33eac +size 76745884 diff --git a/com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a b/com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a index 3e2212833..ace968739 100644 --- a/com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a +++ b/com.unity.uiwidgets/Runtime/Plugins/ios/libUIWidgets.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:845d1eb0cab9827127f8758e5393fbc12191fae907edffab8a2d29db5425c945 -size 247828112 +oid sha256:396a30ebbb3f08f5b1521b31a8cb153ad7b018872bd7b048c115ca5e794de804 +size 247821744 diff --git a/com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib b/com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib index e006caa45..0a1150c4e 100755 --- a/com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib +++ b/com.unity.uiwidgets/Runtime/Plugins/osx/libUIWidgets.dylib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:45bc8d2b586ede8e9dae7ce5f660b4cbadf0994d0d7b4d28e7c2fd6211d116fa -size 21819832 +oid sha256:56d3a89a2b7c6ad6f8f95299151fddc139f422261081af729bcd048e3644eb4d +size 21819568