Fix Android crash on resume with wgpu#3847
Conversation
Garoven
left a comment
There was a problem hiding this comment.
I think it is the way it should be done
|
|
||
| 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.
Fwiw winit is built to emit Resumed on all platforms. Can the initialization be done here, generically?
There was a problem hiding this comment.
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.
- 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.
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.
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