mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 22:50:19 +00:00
5d110eb96e
# Objective This PR addresses the issue where Bevy displays one or several black frames before the scene is first rendered. This is particularly noticeable on iOS, where the black frames disrupt the transition from the launch screen to the game UI. I have written about my search to solve this issue on the Bevy discord: https://discord.com/channels/691052431525675048/1151047604520632352 While I can attest this PR works on both iOS and Linux/Wayland (and even seems to resolve a slight flicker during startup with the latter as well), I'm not familiar enough with Bevy to judge the full implications of these changes. I hope a reviewer or tester can help me confirm whether this is the right approach, or what might be a cleaner solution to resolve this issue. ## Solution I have moved the "startup phase" as well as the plugin finalization into the `app.run()` function so those things finish synchronously before the "main schedule" starts. I even move one frame forward as well, using `app.update()`, to make sure the rendering has caught up with the state of the finalized plugins as well. I admit that part of this was achieved through trial-and-error, since not doing the "startup phase" *before* `app.finish()` resulted in panics, while not calling an extra `app.update()` didn't fully resolve the issue. What I *can* say, is that the iOS launch screen animation works in such a way that the OS initiates the transition once the framework's [`didFinishLaunching()`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622921-application) returns, meaning app developers **must** finish setting up their UI before that function returns. This is what basically led me on the path to try to "finish stuff earlier" :) ## Changelog ### Changed - The startup phase and the first frame are rendered synchronously when calling `app.run()`, before the "main schedule" is started. This fixes black frames during the iOS launch transition and possible flickering on other platforms, but may affect initialization order in your application. ## Migration Guide Because of this change, the timing of the first few frames might have changed, and I think it could be that some things one may expect to be initialized in a system may no longer be. To be honest, I feel out of my depth to judge the exact impact here. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |