Skip to content
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

Merged
merged 63 commits into from
Jun 3, 2024

Conversation

pietrosophya
Copy link
Contributor

@pietrosophya pietrosophya commented May 14, 2024

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 and Reactive, but the latter exposes 3 new properties to enable reactive to device, user or window events. The previous UpdateMode::Reactive is now equivalent to UpdateMode::reactive(), while UpdateMode::ReactiveLowPower to UpdateMode::reactive_low_power().

The ApplicationLifecycle has been renamed as AppLifecycle, and now contains the possible values of the application state inside the event loop:

  • Idle: the loop has not started yet
  • Running (previously called Started): the loop is running
  • WillSuspend: the loop is going to be suspended
  • Suspended: the loop is suspended
  • WillResume: the loop is going to be resumed

Note: the Resumed state has been removed since the resumed app is just running.

Finally, now that winit enables this, it extends the WinitPlugin to support custom events.

Test platforms

  • Windows
  • MacOs
  • Linux (x11)
  • Linux (Wayland)
  • Android
  • iOS
  • WASM/WebGPU
  • WASM/WebGL2

Outstanding issues / regressions

  • iOS: build failed in CI
    • blocking, but may just be flakiness
  • Cross-platform: when the window is maximised, changes in the scale factor don't apply, to make them apply one has to make the window smaller again. (Re-maximising keeps the updated scale factor)
    • non-blocking, but good to fix
  • Android: it's pretty easy to quickly open and close the app and then the music keeps playing when suspended.
    • non-blocking but worrying
  • Web: the application will hang when switching tabs
  • Cross-platform?: Screenshot failure, ERROR present_frames: wgpu_core::present: No work has been submitted for this frame before taking the first screenshot, but after pressing space
    • non-blocking, but good to fix

@alice-i-cecile alice-i-cecile added this to the 0.14 milestone May 14, 2024
@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in C-Dependencies A change to the crates that Bevy depends on D-Complex Quite challenging from either a design or technical perspective. Ask for help! X-Uncontroversial This work is generally agreed upon S-Needs-Testing Testing must be done before this is safe to merge labels May 14, 2024
@alice-i-cecile
Copy link
Member

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.

@pietrosophya
Copy link
Contributor Author

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.

@hymm
Copy link
Contributor

hymm commented May 14, 2024

I think android support is broken without the update. See this message from Francois #13254 (comment)

@pietrosophya pietrosophya marked this pull request as ready for review May 15, 2024 14:50
@mockersf
Copy link
Member

mockersf commented Jun 1, 2024

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

@tychedelia
Copy link
Contributor

Could you give me more details on the iOS build failure? I don't see it in CI, I'll try to reproduce tomorrow

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

examples/mobile/Makefile Outdated Show resolved Hide resolved
@aevyrie
Copy link
Member

aevyrie commented Jun 2, 2024

FYI: this fixes an issue on main, where mouse inputs are only reported every other frame on MacOS.

@tychedelia
Copy link
Contributor

FYI: this fixes an issue on main, where mouse inputs are only reported every other frame on MacOS.

Oh wow, just tested and this is extremely noticeable on one of my apps running in debug mode. I was wondering yesterday how it could possibly feel so sluggish. Huge fix!

I am seeing an issue however around startup where there is some rescaling visible.

Screen.Recording.2024-06-02.at.9.39.46.AM.mov

In this video it's pretty instant but it's seemed to hang just a bit longer a few times.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Testing Testing must be done before this is safe to merge labels Jun 2, 2024
@alice-i-cecile
Copy link
Member

@pietrosophya once you commit the changes suggested in #13366 (comment) to fix the iOS build I'll merge this in.

@Friz64
Copy link
Contributor

Friz64 commented Jun 2, 2024

FYI: this fixes an issue on main, where mouse inputs are only reported every other frame on MacOS.

I think it has also been happening to me on Wayland. Oh wow.

@pietrosophya once you commit the changes suggested in #13366 (comment) to fix the iOS build I'll merge this in.

Sophya#7 is also still waiting.

@aevyrie
Copy link
Member

aevyrie commented Jun 3, 2024

FYI: this fixes an issue on main, where mouse inputs are only reported every other frame on MacOS.

It appears the issue is not completely fixed, there are still frames where inputs are missing, but it is measureably improved.

@pietrosophya
Copy link
Contributor Author

pietrosophya commented Jun 3, 2024

Patch #7 applied, and also accepted/reverted the change for building iOS

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jun 3, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 3, 2024
Merged via the queue into bevyengine:main with commit 061bee7 Jun 3, 2024
32 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jun 3, 2024
…raits" (#13414)

# Objective

- #13347 was good actually

## Solution

- Add it back to main (once #13366 is merged)

---------

Co-authored-by: Alice Cecile <[email protected]>
@alice-i-cecile
Copy link
Member

Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1328 if you'd like to help out.

@pietrosophya pietrosophya deleted the fix/upgrade-winit-0.30 branch June 5, 2024 09:39
knutsoned pushed a commit to knutsoned/bevy that referenced this pull request Jun 25, 2024
- Upgrade winit to v0.30
- Fixes bevyengine#13331

This is a rewrite/adaptation of the new trait system described and
implemented in `winit` v0.30.

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](https://github.com/bevyengine/bevy/pull/13366/files#diff-2de8c0a8d3028d0059a3d80ae31b2bbc1cde2595ce2d317ea378fe3e0cf6ef2d)
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` and
`Reactive`, but the latter exposes 3 new properties to enable reactive
to device, user or window events. The previous `UpdateMode::Reactive` is
now equivalent to `UpdateMode::reactive()`, while
`UpdateMode::ReactiveLowPower` to `UpdateMode::reactive_low_power()`.

The `ApplicationLifecycle` has been renamed as `AppLifecycle`, and now
contains the possible values of the application state inside the event
loop:
* `Idle`: the loop has not started yet
* `Running` (previously called `Started`): the loop is running
* `WillSuspend`: the loop is going to be suspended
* `Suspended`: the loop is suspended
* `WillResume`: the loop is going to be resumed

Note: the `Resumed` state has been removed since the resumed app is just
running.

Finally, now that `winit` enables this, it extends the `WinitPlugin` to
support custom events.

- [x] Windows
- [x] MacOs
- [x] Linux (x11)
- [x] Linux (Wayland)
- [x] Android
- [x] iOS
- [x] WASM/WebGPU
- [x] WASM/WebGL2

- [ ] iOS: build failed in CI
   - blocking, but may just be flakiness
- [x] Cross-platform: when the window is maximised, changes in the scale
factor don't apply, to make them apply one has to make the window
smaller again. (Re-maximising keeps the updated scale factor)
    - non-blocking, but good to fix
- [ ] Android: it's pretty easy to quickly open and close the app and
then the music keeps playing when suspended.
    - non-blocking but worrying
- [ ]  Web: the application will hang when switching tabs
- Not new, duplicate of bevyengine#13486
- [ ] Cross-platform?: Screenshot failure, `ERROR present_frames:
wgpu_core::present: No work has been submitted for this frame before`
taking the first screenshot, but after pressing space
    - non-blocking, but good to fix

---------

Co-authored-by: François <[email protected]>
knutsoned pushed a commit to knutsoned/bevy that referenced this pull request Jun 25, 2024
…raits" (bevyengine#13414)

# Objective

- bevyengine#13347 was good actually

## Solution

- Add it back to main (once bevyengine#13366 is merged)

---------

Co-authored-by: Alice Cecile <[email protected]>
@HugoPeters1024
Copy link
Contributor

I'm in the process of migrating my custom rendering backend to work with Bevy 0.14 and I'm running into trouble because the RawWindowHandleWrapperHolder contains a None value when initializing my rendering plugin. At what point can I rely on the value being set?

patrickariel pushed a commit to patrickariel/bevy that referenced this pull request Sep 11, 2024
…raits" (bevyengine#13414)

# Objective

- bevyengine#13347 was good actually

## Solution

- Add it back to main (once bevyengine#13366 is merged)

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Dependencies A change to the crates that Bevy depends on D-Complex Quite challenging from either a design or technical perspective. Ask for help! M-Needs-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bevy mobile example crashes on Android