Skip to content

Conversation

@MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Nov 23, 2025

Fixes #3206

Surface creation and destruction events exist "specifically" for Android which has diverging lifetimes for its Surface structure compared to other platforms; specifically Vulkan VkSurfaceKHR or EGLSurface objects need to be destroyed and recreated.

Commit 6cdb317 ("Consistently deliver a Resumed event on all platforms") made sure to consistently call can_create_surfaces() (Event::Resumed back then) on all platforms directly after startup so that users don't have to have platform-specific surface creation behaviour in two disjoint places, but we forgot about destroy_surfaces() (back then Event::Suspended) leading to applications still having to handle this destruction in two different places.

Solve that by calling the callback on all those platforms, directly before returning PumpStatus::Exit from fn single_iteration().

Important

Draft because this is entirely untested and may not even compile on all platforms. The samples likely still need to be updated to match the new behaviour too.

In a distant future (before Winit 0.31 perhaps) these events should perhaps be moved to WindowEvent.

Surface creation and destruction events exist "specifically" for Android
which has diverging lifetimes for its `Surface` structure compared to
other platforms; specifically Vulkan `VkSurfaceKHR` or `EGLSurface`
objects need to be destroyed and recreated.

Commit 6cdb317 ("Consistently deliver a Resumed event on all
platforms") made sure to consistently call `can_create_surfaces()`
(`Event::Resumed` back then) on all platforms directly after
startup so that users don't have to have platform-specific surface
creation behaviour in two disjoint places, but we forgot about
`destroy_surfaces()` (back then `Event::Suspended`) leading to
applications still having to handle this destruction in two different
places.

Solve that by calling the callback on all those platforms, directly
before returning `PumpStatus::Exit` from `fn single_iteration()`.
@MarijnS95 MarijnS95 changed the title Emit destroy_surfaces() event consistently on all platforms Emit destroy_surfaces() consistently on all platforms Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Emit destroy_surfaces() on every platform before LoopDestroyed for surface-cleanup feature parity?

1 participant