Skip to content

hal-gal: fix EGL_BAD_ACCESS after first frame by moving capture off init thread#142

Merged
sundermann merged 1 commit into
webosbrew:mainfrom
sundermann:fix-hal-gal-egl-thread
Jul 4, 2026
Merged

hal-gal: fix EGL_BAD_ACCESS after first frame by moving capture off init thread#142
sundermann merged 1 commit into
webosbrew:mainfrom
sundermann:fix-hal-gal-egl-thread

Conversation

@sundermann

Copy link
Copy Markdown
Contributor

HAL_GAL_CaptureFrameBuffer() was being called once during capture_init(), which runs on the caller's setup thread. However, actual frame capture happens later via capture_acquire_frame(), invoked from unicapture's dedicated capture thread spawned in unicapture_start().

HAL_GAL_Init() appears to bind an EGL/GL context to the calling thread, and that binding is thread-affine. Capturing a frame during init bound the context to the wrong thread, causing every subsequent capture from the real worker thread to fail with EGL_BAD_ACCESS (0x3002).

Removing the init-time capture call means the surface is only ever captured from the capture thread, fixing continuous capture after the first frame.

…nit thread

HAL_GAL_CaptureFrameBuffer() was being called once during capture_init(), which runs on the caller's setup thread. However, actual frame capture happens later via capture_acquire_frame(), invoked from unicapture's dedicated capture thread spawned in unicapture_start().

HAL_GAL_Init() appears to bind an EGL/GL context to the calling thread, and that binding is thread-affine. Capturing a frame during init bound the context to the wrong thread, causing every subsequent capture from the real worker thread to fail with EGL_BAD_ACCESS
(0x3002).

Removing the init-time capture call means the surface is only ever captured from the capture thread, fixing continuous capture after
the first frame.
@satgit62

satgit62 commented Jul 4, 2026

Copy link
Copy Markdown

HAL_GAL_CaptureFrameBuffer() was being called once during capture_init(), which runs on the caller's setup thread. However, actual frame capture happens later via capture_acquire_frame(), invoked from unicapture's dedicated capture thread spawned in unicapture_start().

HAL_GAL_Init() appears to bind an EGL/GL context to the calling thread, and that binding is thread-affine. Capturing a frame during init bound the context to the wrong thread, causing every subsequent capture from the real worker thread to fail with EGL_BAD_ACCESS (0x3002).

Removing the init-time capture call means the surface is only ever captured from the capture thread, fixing continuous capture after the first frame.

Hi, that looks good, and it makes sense to remove the init-time capture call.

@satgit62

satgit62 commented Jul 4, 2026

Copy link
Copy Markdown

@sundermann
It has now been tested on webOS, and the fix works. Thank you!
See: https://discord.com/channels/407937994037919756/931706504627773450/1522942285787172914

@sundermann sundermann merged commit 4c5d364 into webosbrew:main Jul 4, 2026
2 checks passed
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