Skip to content

fix(android): destroy SinkSurface on the GL thread - #248

Merged
parkergrt merged 1 commit into
pixpark:mainfrom
rainboy93:fix/sink-surface-gl-thread-teardown
Sep 26, 2026
Merged

parkergrt merged 1 commit into
pixpark:mainfrom
rainboy93:fix/sink-surface-gl-thread-teardown

Conversation

@rainboy93

Copy link
Copy Markdown
Contributor

Problem

nativeDestroy, nativeFinalize and nativeReleaseSurface tear down an EGL surface and delete a GL program from whatever thread calls them — in practice the main thread, from an Android lifecycle callback, with no GL context current. Construction already hops onto GPUPixel's GL thread via SyncRunWithContext; teardown did not. This can corrupt EGL state and abort later, far from the cause (e.g. a pthread_mutex FORTIFY check).

Fix

Run the three teardown paths through GPUPixelContext::SyncRunWithContext so they hold the context, and null-check the pointer in nativeDestroy before delete.

Verified on Android: repeated attach/detach cycles with no EGL error or abort.

nativeDestroy/nativeFinalize/nativeReleaseSurface tear down an EGL
surface and GL program from whatever thread calls them — in practice the
main thread from an Android lifecycle callback, with no GL context
current. Construction already hops onto GPUPixel's GL thread; teardown
did not, so it could corrupt EGL state and abort later with an error far
from the cause (e.g. a mutex FORTIFY check). Run teardown via
SyncRunWithContext, and null-check before delete.
@parkergrt
parkergrt merged commit 47e432b into pixpark:main Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants