WebPlatformForEmbedded / WPEWebKit

WPE WebKit port (downstream)
211 stars 135 forks source link

[2.38] Destroy acc surface and egl target in nonCompositedWebGL mode #1230

Closed asurdej-comcast closed 9 months ago

asurdej-comcast commented 9 months ago

In case of nonCompositedWebGL enabled (Lightning) egl target from renderer backend was never destroyed that was causing crash on egl backend destruction as the backend outlived the target.

This change ensures that egl target is destroyed on LayerTreeHost and ThreadedCompositor destruction freeing native window.

Also need to ensure that static window context from NicosiaGCGLLayer is destroyed before egl target destruction (otherwise it will crash). Add ref counting and destroy global window context when no longer needed. (Can be recreated if neccesary)

asurdej-comcast commented 9 months ago

Hi @magomez Can you please take a look here. It is connected to other changes like https://github.com/WebPlatformForEmbedded/WPEWebKit/issues/1134

With this patch we will rely on webkit destruction to destroy compositor resource (native window) as part of egl target destruction so no additional changes for 1134 are needed

magomez commented 9 months ago

@asurdej-comcast I like the approach that you're using to destroy the static context in NicosiaGLGLLayer. But I don't understand what you're doing in the ThreadedCompositor. If this is targeting the nonCompositedWebGL mode only, then changes to the ThreadedCompositor are not required, as it won't really hold any GL resource.

magomez commented 9 months ago

Ah, I get it now. LGTM.

asurdej-comcast commented 9 months ago

Thanks, ThrededCompositor patch is to trigger egl_target_destroy that is called via didDestroyGLContext() -> LayerTreeHost::didDestroyGLContext() -> AcceleratedSurfaceLibWPE::finalize()