Closed Bug 1898238 Opened 2 years ago Closed 2 years ago

Allow using SharedSurface_EGLImage for oop-webgl and accelerated canvas on Android

Categories

(Core :: Graphics, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

Details

Attachments

(5 external files)

We haven't used this in a while. (I'm guessing since e10s shipped, because EGL images cannot be sent cross-process.) But since accelerated canvas and webgl live in the GPU process nowadays, we can in theory use it again. It avoids the glitches in bug 1892716, for example.

It has bitrotted somewhat, so some work needs to be done to SharedSurface_EGLImage and (Render)EGLImageTextureHost to get it to work.

This is only used if the OffscreenCanvas has a webgl context, in which
case it forwards the tex type to WebGLContext::PresentFrontBuffer(). A
later patch in this series will make TexTypeForWebgl() return a
different value depending on whether the webgl context is in-process
or remote, which is something that cannot be known when the
OffscreenCanvas is initialized. This patch therefore removes the field
from OffscreenCanvas and makes WebGLContext::PresentFrontBuffer() call
TexTypeForWebgl() itself.

HandleExternalImage() has two nearly identical code paths for
rendering either RenderAndroidSurfaceTextureHost or
RenderAndroidHardwareBufferTextureHost using CompositorOGL. The next
patch in this series will additionally add support for
RenderEGLImageTextureHost. Rather than duplicate the code yet again,
we abstract the differences in to a new virtual function
RenderTextureHost::CreateTextureSource() and use a single common code
path in HandleExternalImage().

SharedSurface_EGLImage has mostly avoided bitrotting. However, it now
sometimes gets destructed after the GLContext has been lost, resulting
in a crash when attempting to clean up its resources. To avoid this,
we hold a weak reference to the EglDisplay, and use that to clean up
rather than the GLContext.

To support rendering with SWGL, EGLImageTextureHost ensures the
correct preferCompositorSurface, supportsExternalCompositing, and
imageType values are sent to webrender. RenderEGLImageTextureHost now
implements RenderTextureHostSWGL, as well as the new
CreateTextureSource() function, and EGLImageTextureSource is
initialized with a GL context reference so that it may actually work.

Additionally we use eglWaitSync() rather than eglClientWaitSync()
where available for improved performance. And we ensure that we bind
the EGL images' textures to GL_TEXTURE_2D rather than
GL_TEXTURE_EXTERNAL when running on the Android emulator to work
around the buggy implementation in some emulator versions.

We must ensure that a SharedSurface_EGLImage outlives its
corresponding RenderEGLImageTextureHost, so that
RenderEGLImageTextureHost does not attempt to wait on an EGLSync that
has been destroyed. This can be achieved by passing the surface to
RemoteTextureOwnerClient::PushTexture(), ensuring the RemoteTextureMap
keeps it alive.

However, we must be careful not to recycle the SharedSurface_EGLImage,
as that is currently not supported. To achieve this, we make
RemoteTextureMap::RecycleTexture() only recycle SharedSurfaces whose
mDesc.canRecycle value is true.

Adds a pref wegb.enable-egl-image which is true by default. When
enabled, we use EGL images as the preferred texture type for
out-of-process webgl and accelerated canvas on Android. In-process
webgl will never attempt to use EGL images, regardless of the value of
the pref, as we are unable to send EGL images cross-process.

Pushed by jnicol@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/19fa8d4af66f Don't call TexTypeForWebgl when initializing offscreen canvas. r=aosmond,jgilbert https://hg.mozilla.org/integration/autoland/rev/332c668a15bc Tidy up RenderCompositorOGLSWGL::HandleExternalImage. r=sotaro https://hg.mozilla.org/integration/autoland/rev/6359e558d765 Make SharedSurface_EGLImage and (Render)EGLImageTextureHost work. r=sotaro,jgilbert https://hg.mozilla.org/integration/autoland/rev/549abd685d11 Keep SharedSurface_EGLImages alive but do not recycle them. r=sotaro,jgilbert https://hg.mozilla.org/integration/autoland/rev/ae8e94c8f819 Use SharedSurface_EGLImage for out-of-process webgl and accelerated canvas on Android. r=sotaro,jgilbert

Backed for causing non unified build bustages on RenderEGLImageTextureHost.cpp.

[task 2024-07-22T16:33:37.156Z] 16:33:37     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -o RenderEGLImageTextureHost.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DMOZ_SUPPORT_LEAKCHECKING -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/gfx/webrender_bindings -I/builds/worker/workspace/obj-build/gfx/webrender_bindings -I/builds/worker/workspace/obj-build/ipc/ipdl/_ipdlheaders -I/builds/worker/checkouts/gecko/ipc/chromium/src -I/builds/worker/checkouts/gecko/gfx/cairo/cairo/src -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -D_GLIBCXX_USE_CXX11_ABI=0 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Werror -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/gtk-3.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/glib-2.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/cairo -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/pixman-1 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/libpng12 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/gdk-pixbuf-2.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/gio-unix-2.0/ -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/harfbuzz -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/atk-1.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/at-spi2-atk/2.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/at-spi-2.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/dbus-1.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/gtk-3.0/unix-print -pthread -Werror=switch -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/RenderEGLImageTextureHost.o.pp   /builds/worker/checkouts/gecko/gfx/webrender_bindings/RenderEGLImageTextureHost.cpp
[task 2024-07-22T16:33:37.157Z] 16:33:37    ERROR -  /builds/worker/checkouts/gecko/gfx/webrender_bindings/RenderEGLImageTextureHost.cpp:123:10: error: 'return' will never be executed [-Werror,-Wunreachable-code-return]
[task 2024-07-22T16:33:37.158Z] 16:33:37     INFO -    123 |   return true;
[task 2024-07-22T16:33:37.159Z] 16:33:37     INFO -        |          ^~~~
[task 2024-07-22T16:33:37.159Z] 16:33:37     INFO -  1 error generated.
[task 2024-07-22T16:33:37.160Z] 16:33:37    ERROR -  gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:675: RenderEGLImageTextureHost.o] Error 1
[task 2024-07-22T16:33:37.161Z] 16:33:37     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/webrender_bindings'
[task 2024-07-22T16:33:37.162Z] 16:33:37     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/webrender_bindings'
[task 2024-07-22T16:33:37.163Z] 16:33:37     INFO -  gfx/webrender_bindings/RenderSharedSurfaceTextureHost.o
[task 2024-07-22T16:33:37.164Z] 16:33:37     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/webrender_bindings'
[task 2024-07-22T16:33:37.258Z] 16:33:37     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/gfx/skia'
[task 2024-07-22T16:33:37.263Z] 16:33:37     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -o SkScan.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -DNDEBUG=1 -DTRIMMED=1 -DMOZ_SKIA -DSKIA_IMPLEMENTATION=1 -DSK_PDF_USE_HARFBUZZ_SUBSETTING=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DMOZ_SUPPORT_LEAKCHECKING -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/gfx/skia -I/builds/worker/workspace/obj-build/gfx/skia -I/builds/worker/checkouts/gecko/gfx/skia/skia -I/builds/worker/checkouts/gecko/gfx/cairo/cairo/src -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -D_GLIBCXX_USE_CXX11_ABI=0 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -fcrash-diagnostics-dir=/builds/worker/artifacts -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtautological-constant-in-range-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Wenum-float-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wformat -Wformat-security -Wno-psabi -Wthread-safety -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-deprecated-declarations -Wno-overloaded-virtual -Wno-sign-compare -Wno-unreachable-code -Wno-unused-function -Wno-implicit-fallthrough -Wno-inconsistent-missing-override -Wno-macro-redefined -Wno-unused-private-field -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/pango-1.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include/glib-2.0 -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/include -pthread -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/SkScan.o.pp   /builds/worker/checkouts/gecko/gfx/skia/skia/src/core/SkScan.cpp
[task 2024-07-22T16:33:37.264Z] 16:33:37     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/gfx/skia'
Flags: needinfo?(jnicol)
Flags: needinfo?(jnicol)
Pushed by jnicol@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4b60c438e5d6 Don't call TexTypeForWebgl when initializing offscreen canvas. r=aosmond,jgilbert https://hg.mozilla.org/integration/autoland/rev/1b2832c0fac8 Tidy up RenderCompositorOGLSWGL::HandleExternalImage. r=sotaro https://hg.mozilla.org/integration/autoland/rev/a2691ee38a5e Make SharedSurface_EGLImage and (Render)EGLImageTextureHost work. r=sotaro,jgilbert https://hg.mozilla.org/integration/autoland/rev/7e0171e88041 Keep SharedSurface_EGLImages alive but do not recycle them. r=sotaro,jgilbert https://hg.mozilla.org/integration/autoland/rev/a4031c701928 Use SharedSurface_EGLImage for out-of-process webgl and accelerated canvas on Android. r=sotaro,jgilbert
Regressions: 1910516
Regressions: 1914774
See Also: → 1810658
See Also: → 2064312
See Also: → 2066020
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: