-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: upgrade to winit v0.30 #13366
base: main
Are you sure you want to change the base?
fix: upgrade to winit v0.30 #13366
Conversation
Does anyone have opinions on squeezing this into 0.14 vs merging it at the start of 0.15? On the one hand fixes are great, on the other hand these upgrade PRs are consistently incredibly painful to review and introduce a large number of new bugs that must be manually tested. |
IMHO, this could be finished and merged as part of 0.14: I only moved code from free variables and functions inside the WinitAppRunnerState, not really changing any logic. Also, apart from testing it, the number of missing/required changes is not high: I just need to understand better the AccessKit part, restore the exit flags (that aren't currently working) and compile/test the various platforms. The low_power example (and I believe others too) in MacOS works already. |
I think android support is broken without the update. See this message from Francois #13254 (comment) |
I have tested on webgl2, the application will hang when switched tabs. Something like this #13486 |
Can reproduce on macOS: Screenshots: |
I've asked for help with this PR over in the winit Matrix chat: link. |
I did some more testing on Android and it seems that the crashing might be a MIUI quirk. After clearing other background apps, the crashing went away. Sorry for the noise.
I also did some more investigation on this. It is still an issue. It seems that the suspended-function is just never called by winit if the app is closed early enough (at least on my device with Android 11). I don't know if we can do much about it. It is a regression, but maybe not worth blocking over imo. Otherwise suspension works fine. |
ApplicationLifetime::Suspended => music_controller.single().pause(), | ||
ApplicationLifetime::Resumed => music_controller.single().play(), | ||
ApplicationLifetime::Started => (), | ||
AppLifecycle::Idle | AppLifecycle::WillSuspend | AppLifecycle::WillResume => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be included in the event enum? In my testing none of these three are ever sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idle is correct (probably?) because it happens when the app just started only (and it's never reset). The other 2 though should happen but I could have missed sending them.
I have no opinions on sending Idle, it seems useless apart from initializing the state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idle is never sent because lifecycle events are only sent when changed, and Idle is never changed into. WillSuspend and WillResume events are never sent because the lifecycle is always immediately changed to Suspend or Running before sending the change.
Sending idle seems pretty useless anyway when it is the default and never seen after startup.
I also tested with opt-level=3 and lto="thin", and then the time window for making the music bug happen is very very small. I couldn't make it happen in practice, maybe it would be easier on a slower device or with more stuff happening in startup. Edit: tried with 4 second sleep in the |
I think this is related to 2 combined things happening:
I can handle both in this PR or in a follow up one in the next couple days. |
I fixed the scale factor override issue and solved this 🤞 |
Can confirm it works! |
@mockersf is there an easy way to test the IOS build that's failing? it seems the only blocker to merge this PR now... |
Could you give me more details on the iOS build failure? I don't see it in CI, I'll try to reproduce tomorrow also, another patch update please: Sophya#7 |
Seems like iOS is skipped? This happened last time it was added to the merge queue: https://github.com/bevyengine/bevy/actions/runs/9215755498/job/25354702941 |
@@ -2,7 +2,7 @@ | |||
|
|||
DEVICE = ${DEVICE_ID} | |||
ifndef DEVICE_ID | |||
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v '^--' | grep -v '==' | head -n 1 | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") | |||
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v 'Shutdown' | grep -v '^--' | grep -v '==' | head -n 1 | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v 'Shutdown' | grep -v '^--' | grep -v '==' | head -n 1 | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") | |
DEVICE=$(shell xcrun simctl list devices 'iOS' | grep -v 'unavailable' | grep -v '^--' | grep -v '==' | head -n 1 | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change stops CI from finding the simulator and is unrelated to this PR
Objective
Solution
This is a rewrite/adaptation of the new trait system described and implemented in
winit
v0.30.Migration Guide
The custom UserEvent is now renamed as WakeUp, used to wake up the loop if anything happens outside the app (a new custom_user_event shows this behavior.
The internal
UpdateState
has been removed and replaced internally by the AppLifecycle. When changed, the AppLifecycle is sent as an event.The
UpdateMode
now accepts only two values:Continuous
andReactive
, but the latter exposes 3 new properties to enable reactive to device, user or window events. The previousUpdateMode::Reactive
is now equivalent toUpdateMode::reactive()
, whileUpdateMode::ReactiveLowPower
toUpdateMode::reactive_low_power()
.The
ApplicationLifecycle
has been renamed asAppLifecycle
, and now contains the possible values of the application state inside the event loop:Idle
: the loop has not started yetRunning
(previously calledStarted
): the loop is runningWillSuspend
: the loop is going to be suspendedSuspended
: the loop is suspendedWillResume
: the loop is going to be resumedNote: the
Resumed
state has been removed since the resumed app is just running.Finally, now that
winit
enables this, it extends theWinitPlugin
to support custom events.Test platforms
Outstanding issues / regressions
winit::TabLeft
/Event::Suspended
doesn't function as intended on WASM #13486ERROR present_frames: wgpu_core::present: No work has been submitted for this frame before
taking the first screenshot, but after pressing space