-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 Android crash on resume with wgpu
#3847
Conversation
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.
I think it is the way it should be done
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.
Great - thanks!
@@ -386,6 +412,8 @@ impl WinitApp for WgpuWinitApp { | |||
log::debug!("Event::Resumed"); | |||
|
|||
let running = if let Some(running) = &self.running { | |||
#[cfg(target_os = "android")] | |||
self.recreate_window(event_loop, running); |
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.
Fwiw winit
is built to emit Resumed
on all platforms. Can the initialization be done here, generically?
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.
In the same way we're looking to consistently emit Suspended
before the loop is destroyed, giving users a consistent place to clean up their swapchain.
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.
- On platforms other than Android, Ios and Web Resume event is only send once when loop starts running. So the recreation for other platforms won't happen and for Ios and Web the Suspend/Resume cycle is different.
- The same for Suspend event it only occurs for Android, Ios and Web.
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.
On other platforms it is not about recreating, it is about initially creating this state in the same place instead of having unnecessary conditionals in eframe
.
Destruction only happens in ::Suspended
.
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.
Okay this looks much harder to fix than thought. WgpuWinitRunning
contains a lot of state that should easily live outside the Android surface lifecycle.
glow might need the same thing but it might be more subtly broken because App->MultiTask->anything->App works but App->Home->App breaks |
@m-hugo that's likely not going to be solvable without a significant rearchitecturing of This might be worked around by changing the launch/taskmode in the manifest, or maybe the shutdown path isn't implemented in |
but it works on wgpu and worked on glow before? |
Then the lifetime cycle is perhaps not implemented correctly? That doesn't seem too surprising given that this PR hides it behind |
I actually forgot about glow backend. But it seems fix for it very similar. Sadly Wgpu and Glow differ to much to make it generic. |
It looks like |
Addition for <#3847> In previous one i only fixed crash occurring with Wgpu backend. This fixes crash with Glow backend as well. I only tested this change with android so most things i changed are behind ```#[cfg(target_os = "android")]```. Both fixes are dirty thought. As <#3172> says that "The root viewport is the original viewport, and cannot be closed without closing the application.". So they break rules i guess? But i can't think about better solution for now. Closes <#3861>.
wgpu
Added Viewport reinitialization and Window recreation for Android on resume event.
Closes #3674.
fix.mp4