Create the EGLContext on the thread it will be used on.

Not doing so seems to have caused issues with creating window surfaces
on that context later on.

Bug: b/225229697
Change-Id: Id202c93c4e51d1661e79a4b37751d11fcd64c119
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/311462
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Commit-Queue: Linus Nilsson <lnilsson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40411}
This commit is contained in:
Linus Nilsson 2023-07-10 11:24:21 +02:00 committed by WebRTC LUCI CQ
parent f186e32d9e
commit 4e5b89f77b

View File

@ -33,15 +33,19 @@ public class EglThread {
renderThread.start();
Handler handler = new Handler(renderThread.getLooper());
// If sharedContext is null, then texture frames are disabled. This is typically for old
// devices that might not be fully spec compliant, so force EGL 1.0 since EGL 1.4 has
// caused trouble on some weird devices.
EglConnection eglConnection;
if (sharedContext == null) {
eglConnection = EglConnection.createEgl10(configAttributes);
} else {
eglConnection = EglConnection.create(sharedContext, configAttributes);
}
// Not creating the EGLContext on the thread it will be used on seems to cause issues with
// creating window surfaces on certain devices. So keep the same legacy behavior as EglRenderer
// and create the context on the render thread.
EglConnection eglConnection = ThreadUtils.invokeAtFrontUninterruptibly(handler, () -> {
// If sharedContext is null, then texture frames are disabled. This is typically for old
// devices that might not be fully spec compliant, so force EGL 1.0 since EGL 1.4 has
// caused trouble on some weird devices.
if (sharedContext == null) {
return EglConnection.createEgl10(configAttributes);
} else {
return EglConnection.create(sharedContext, configAttributes);
}
});
return new EglThread(
releaseMonitor != null ? releaseMonitor : eglThread -> true, handler, eglConnection);