Skip to content

Commit 673272f

Browse files
author
Anu Aliyas
committed
Fix crash on macOS
The recent chromium changes caches different displays and perform a deferred wait operation, which leads to accessing command buffers from different threads, as the QtWebengine invokes these deferred wait calls from the main thread. The current fix attempt is to not defer the calls and execute them on the current thread itself. amends 2e0bedfdf9aa7d9b7d3995410b251da39eb4de91 Fixes: QTBUG-128846 Change-Id: Iaf97121a626369bdec3879a3b61b7bb20e5a9241 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/596078 Reviewed-by: Michal Klocek <[email protected]>
1 parent 4994cc3 commit 673272f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

chromium/gpu/command_buffer/service/shared_image/iosurface_image_backing.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,14 @@ class GPU_GLES2_EXPORT IOSurfaceImageBacking
141141
void WaitForDawnCommandsToBeScheduled(const wgpu::Device& device_to_exclude);
142142
#endif
143143

144+
#if !BUILDFLAG(IS_QTWEBENGINE)
144145
void AddEGLDisplayWithPendingCommands(gl::GLDisplayEGL* display);
146+
#endif
145147
void WaitForANGLECommandsToBeScheduled();
148+
#if !BUILDFLAG(IS_QTWEBENGINE)
146149
void ClearEGLDisplaysWithPendingCommands(
147150
gl::GLDisplayEGL* display_to_exclude);
151+
#endif
148152

149153
std::unique_ptr<gfx::GpuFence> GetLastWriteGpuFence();
150154
void SetReleaseFence(gfx::GpuFenceHandle release_fence);

chromium/gpu/command_buffer/service/shared_image/iosurface_image_backing.mm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,23 +1405,34 @@ new IOSurfaceBackingEGLState(this, egl_display, context,
14051405
}
14061406
#endif // BUILDFLAG(USE_DAWN)
14071407

1408+
#if !BUILDFLAG(IS_QTWEBENGINE)
14081409
void IOSurfaceImageBacking::AddEGLDisplayWithPendingCommands(
14091410
gl::GLDisplayEGL* display) {
14101411
egl_displays_pending_flush_.insert(display);
14111412
}
1413+
#endif
14121414

14131415
void IOSurfaceImageBacking::WaitForANGLECommandsToBeScheduled() {
1416+
#if !BUILDFLAG(IS_QTWEBENGINE)
14141417
for (auto* display : std::move(egl_displays_pending_flush_)) {
14151418
eglWaitUntilWorkScheduledANGLE(display->GetDisplay());
14161419
}
1420+
#else
1421+
gl::GLDisplayEGL* display = gl::GLDisplayEGL::GetDisplayForCurrentContext();
1422+
if (display) {
1423+
eglWaitUntilWorkScheduledANGLE(display->GetDisplay());
1424+
}
1425+
#endif
14171426
}
14181427

1428+
#if !BUILDFLAG(IS_QTWEBENGINE)
14191429
void IOSurfaceImageBacking::ClearEGLDisplaysWithPendingCommands(
14201430
gl::GLDisplayEGL* display_to_exclude) {
14211431
if (std::move(egl_displays_pending_flush_).contains(display_to_exclude)) {
14221432
egl_displays_pending_flush_.insert(display_to_exclude);
14231433
}
14241434
}
1435+
#endif
14251436

14261437
#if BUILDFLAG(USE_DAWN)
14271438
std::unique_ptr<DawnImageRepresentation> IOSurfaceImageBacking::ProduceDawn(
@@ -1738,8 +1749,9 @@ new IOSurfaceBackingEGLState(this, egl_display, context,
17381749
// Note that we don't need to call WaitForANGLECommandsToBeScheduled for other
17391750
// EGLDisplays because it is already done when the previous GL context is made
17401751
// uncurrent. We can simply remove the other EGLDisplays from the list.
1752+
#if !BUILDFLAG(IS_QTWEBENGINE)
17411753
ClearEGLDisplaysWithPendingCommands(/*display_to_exclude=*/display);
1742-
1754+
#endif
17431755
if (gl::GetANGLEImplementation() == gl::ANGLEImplementation::kMetal) {
17441756
// If this image could potentially be shared with another Metal device,
17451757
// it's necessary to synchronize between the two devices. If any Metal
@@ -1857,7 +1869,11 @@ new IOSurfaceBackingEGLState(this, egl_display, context,
18571869
// IOSurface synchronization by the kernel e.g. using waitUntilScheduled on
18581870
// Metal or glFlush on OpenGL. Defer the call until CoreAnimation, Dawn,
18591871
// or another ANGLE EGLDisplay needs to access to avoid unnecessary overhead.
1872+
#if !BUILDFLAG(IS_QTWEBENGINE)
18601873
AddEGLDisplayWithPendingCommands(display);
1874+
#else
1875+
eglWaitUntilWorkScheduledANGLE(display->GetDisplay());
1876+
#endif
18611877

18621878
// When SwANGLE is used as the GL implementation, it holds an internal
18631879
// texture. We have to call ReleaseTexImage here to trigger a copy from that

0 commit comments

Comments
 (0)