gfxFontCache acquires and releases its mutex during various operations.
In order to keep the state internally consistent, we should only release
the lock after the full operation is complete. This involves moving the
deletion of gfxFont to outside the lock via a temporary discard array.
The expiration state should not be protected by the gfxFont's mutex
since we don't hold it during most operations. Instead we should hold
gfxFontCache's mutex because then we can guarantee the operation is
atomic, particularly when a worker wants a font, and the main thread is
aging the generations.
When a font is returned from gfxFontCache, we now return it already
removed from the tracker, and with its refcount updated. This avoids any
potential races between the expiration timer and a worker accessing the
font, as well as simplying the callers so they don't need to be aware of
addref-ing manually in case the result is to be discarded (so that it
gets readded to the tracker).
Differential Revision: https://phabricator.services.mozilla.com/D151821
The prefs handled in this patch are:
apz.paint_skipping.enabled
apz.force_disable_desktop_zooming_scrollbars
apz.mac.enable_double_tap_zoom_touchpad_gesture
dom.event.default_to_passive_touch_listeners
dom.visualviewport.enabled (one use left over)
Differential Revision: https://phabricator.services.mozilla.com/D151795
gfxFontCache acquires and releases its mutex during various operations.
In order to keep the state internally consistent, we should only release
the lock after the full operation is complete. This involves moving the
deletion of gfxFont to outside the lock via a temporary discard array.
The expiration state should not be protected by the gfxFont's mutex
since we don't hold it during most operations. Instead we should hold
gfxFontCache's mutex because then we can guarantee the operation is
atomic, particularly when a worker wants a font, and the main thread is
aging the generations.
When a font is returned from gfxFontCache, we now return it already
removed from the tracker, and with its refcount updated. This avoids any
potential races between the expiration timer and a worker accessing the
font, as well as simplying the callers so they don't need to be aware of
addref-ing manually in case the result is to be discarded (so that it
gets readded to the tracker).
Differential Revision: https://phabricator.services.mozilla.com/D151821
With async present we can now rely on being able to do readbacks from WebGL
in the GPU process, rather than needing CopySnapshotTo to accelerate this in
the content process. Just remove CopySnapshotTo since it doesn't help anymore.
Differential Revision: https://phabricator.services.mozilla.com/D150721
Currently CopyToSwapChain creates spurious copies of the back buffer when SharedSurfaces aren't exportable (= ToSurfaceDescriptor returns Nothing from SharedSurface_Basic). These then later get read back into a CPU memory buffer when PresentFrontBufferToCompositor is used to send the buffer to RemoteTextureMap. This has associated performance and memory costs.
Conceptually, we want Present/CopyToSwapChain to just do the right thing and automatically push buffers to RemoteTextureMap, rather than secondarily needing a hidden call to PresentFrontBufferToCompositor. Then we can get rid of the need to create front buffers whose only purpose is to shuttle data to PresentFrontBufferToCompositor which then shuttles it RemoteTextureMap.
This patch achieves this by refactoring the guts of PresentFrontBufferToCompositor into Present/CopyToSwapChain. The remote texture ids are sent along inside SwapChainOptions if async present is enabled. Those remote texture ids are cached in ClientWebGLContext so that GetFrontBuffer can return them without any subsequent need for an IPDL call.
On the parent side, CopyToSwapChain will now notice if async present is to be used and if a SurfaceFactory does not generate SharedSurfaces that can be exported. In that case it cuts out the middle man and reads from the WebGLFramebuffer's back buffer directly into a CPU buffer to send to RemoteTextureMap.
This also adds a forceAsyncPresent option to SwapChainOptions so that in the future we can have a separate pref for Accelerated Canvas2D that will allow enabling async present independent of the global WebGL pref.
Differential Revision: https://phabricator.services.mozilla.com/D150720
We can't do likewise for reftests and web platform tests because
those test suites disable apz.allow_zooming by default on android.
Differential Revision: https://phabricator.services.mozilla.com/D151576
`vaapitest()` is meant to be a sanity check. If it failed there's
likely something very broken about the driver and we log gfx
warnings accordingly, allowing to debug the problem.
Ensure to force-disable VAAPI in this case but still allow users
to enable the feature in blocklisted cases.
While on it add some additional fixes for issues encoutered while
testing:
- `InitVAAPIConfig()` was not run on X11-only builds, wrongly
setting `sLayersSupportsHardwareVideoDecoding` to `true` there
on allowlisted drivers. Thus replace `MOZ_WAYLAND` with
`MOZ_WIDGET_GTK`, ensuring the "Wayland support missing" warning
is shown in `about:support`.
- `UserForceEnable` must be run before `ForceDisable`, otherwise an
assert is triggered on debug builds. Reorder this.
- `GetFeatureStatus` was run twice for
`FEATURE_HARDWARE_VIDEO_DECODING`, once in `InitAcceleration()` in the
common code path, the again in `InitVAAPIConfig()`. Untangle the common
code path to only run `InitVAAPIConfig()`.
- Use the chance to turn `media.hardware-video-decoding.enabled` into a
static pref so it matches `media.hardware-video-decoding.force-enabled`
Differential Revision: https://phabricator.services.mozilla.com/D150959
`vaapitest()` is meant to be a sanity check. If it failed there's
likely something very broken about the driver and we log gfx
warnings accordingly, allowing to debug the problem.
Ensure to force-disable VAAPI in this case but still allow users
to enable the feature in blocklisted cases.
While on it add some additional fixes for issues encoutered while
testing:
- `InitVAAPIConfig()` was not run on X11-only builds, wrongly
setting `sLayersSupportsHardwareVideoDecoding` to `true` there
on allowlisted drivers. Thus replace `MOZ_WAYLAND` with
`MOZ_WIDGET_GTK`, ensuring the "Wayland support missing" warning
is shown in `about:support`.
- `UserForceEnable` must be run before `ForceDisable`, otherwise an
assert is triggered on debug builds. Reorder this.
- `GetFeatureStatus` was run twice for
`FEATURE_HARDWARE_VIDEO_DECODING`, once in `InitAcceleration()` in the
common code path, the again in `InitVAAPIConfig()`. Untangle the common
code path to only run `InitVAAPIConfig()`.
- Use the chance to turn `media.hardware-video-decoding.enabled` into a
static pref so it matches `media.hardware-video-decoding.force-enabled`
Differential Revision: https://phabricator.services.mozilla.com/D150959
Current implementation quits video overlay rendering on the error. If the error continues, the video overlay is not rendered correctly. Then it seems better to disable video overlay on the error.
Differential Revision: https://phabricator.services.mozilla.com/D151350
Caching the pref values at initialization instead of on demand allows
this code to be threadsafe and accessible from DOM workers.
Differential Revision: https://phabricator.services.mozilla.com/D151365
The loaders need to be destroyed on the main thread. Assertions for
gfxUserFontSet and gfxFontFamily need to be updated for workers.
Depends on D151342
Differential Revision: https://phabricator.services.mozilla.com/D151343
Caching the pref values at initialization instead of on demand allows
this code to be threadsafe and accessible from DOM workers.
Differential Revision: https://phabricator.services.mozilla.com/D151365
The loaders need to be destroyed on the main thread. Assertions for
gfxUserFontSet and gfxFontFamily need to be updated for workers.
Depends on D151342
Differential Revision: https://phabricator.services.mozilla.com/D151343
Inspired by emilio's suggestion in the shader module API patch. This tries to be the most straightforward way to go from the strings coming from IPC to the ones consumed by wgpu.
Differential Revision: https://phabricator.services.mozilla.com/D151024
This patch is a lot of plumbing for not that much functionality. The goal is to align CreateShaderModule's error reporting with the spec.
Creating a shader module is now a dedicated async IPDL message returning the compilation info so that it can be exposed as a promise by the WebGPU API.
Differential Revision: https://phabricator.services.mozilla.com/D146817
If dedicated thread for out-of-process WebGL exists, compositor thread tasks are not delayed by WebGL tasks.
And Bug 1712486 requests that WebGL run on non-compositor thread.
Differential Revision: https://phabricator.services.mozilla.com/D151210
We have to make sure the scroll animations is still responsive at
boundaries even if it's playstate is finished.
This patch includes the update of UpdateFinishedState() to match the
spec, and make sure we still tick scroll animations at finished play state.
Getting a finished state might be strange for scroll animations, and this
might be a spec issue. However, for consistency with JS-generated animations,
we'd like to align the behaviors with other browsers, and make sure we are
still match the definition of finished state in the spec.
Besides, we have to use EndTime() on the compositor so
animation-iteration-count works properly.
Tests are in the last patch.
Differential Revision: https://phabricator.services.mozilla.com/D149940
In webrender, external textures provide an override UV rect which is
not known until during rendering when the texture is actually
resolved. For brush shaders this value is automatically read from the
GPU cache, but for other shaders the UVs are passed as instance
attributes. Currently we use the overridden UV rect correctly for the
composite shader, but not the cs_scale shader.
On Android devices which do not support the
GL_OES_EGL_image_external_essl3 extension, the cs_scale shader is used
to render video in some cases. Because we were not handling the
texture's UV rect correctly, video was being rendered upside down on
some websites as a result.
This patch makes us manually override the scale shader's instance
data's source_rects when the source is an external
texture. Additionally, the cs_scale shader needs adapted to handle the
case where the UV rect is inverted.
Differential Revision: https://phabricator.services.mozilla.com/D151233
Inspired by emilio's suggestion in the shader module API patch. This tries to be the most straightforward way to go from the strings coming from IPC to the ones consumed by wgpu.
Differential Revision: https://phabricator.services.mozilla.com/D151024
This patch is a lot of plumbing for not that much functionality. The goal is to align CreateShaderModule's error reporting with the spec.
Creating a shader module is now a dedicated async IPDL message returning the compilation info so that it can be exposed as a promise by the WebGPU API.
Differential Revision: https://phabricator.services.mozilla.com/D146817
When Surfaces/SurfaceTextures are allocated they are given a handle,
which is a monotonically increasing 32-bit integer. To render
Surfaces, we typically pass the Surface handle to the compositor,
which then looks it up in a map to find the corresponding
SurfaceTexture.
Following a GPU process restart, content may be left with stale
handles referencing SurfaceTextures which no longer exist. Once new
SurfaceTextures are allocated, these stale handles may reference new
SurfaceTextures with no relation to the old handle. This can lead to
rendering the wrong texture. Additionally, we may crash when
allocating "sync" SurfaceTextures, as the previous sync texture for a
certain handle may not have been released yet.
To fix this, this patch combines the existing handle with a new ID
uniquely identifying the process in which the SurfaceTexture was
allocated (or 0 for the parent process). We use a monotonically
increasing value rather than the pid to guard against the new GPU
process possibly having the same pid as the previous instance. We
combine these two 32-bit integers and use the resulting 64-bit integer
as the Surface handle.
Differential Revision: https://phabricator.services.mozilla.com/D150963
The `widget->DispatchInputEvent` codepath only works in gecko CI
configurations, so to allow this to be used for e.g. WebDriver
implement a path that doesn't go via the parent process.
Differential Revision: https://phabricator.services.mozilla.com/D150632
This patch is a lot of plumbing for not that much functionality. The goal is to align CreateShaderModule's error reporting with the spec.
Creating a shader module is now a dedicated async IPDL message returning the compilation info so that it can be exposed as a promise by the WebGPU API.
Differential Revision: https://phabricator.services.mozilla.com/D146817
The last row of data may have less than stride bytes so make sure we
only copy what we need.
This corresponds to cairo:cccc81ccba99600483621e02ae9438a4a5a3d024
Differential Revision: https://phabricator.services.mozilla.com/D151053
This is mostly just changing a small number of structs and function
params (most of the work has been done in previous patches).
Differential Revision: https://phabricator.services.mozilla.com/D150987
Also make the parent in ClipTemplate an Option, so that the
semantics are a bit clearer (follow up patches will remove this
parent field entirely).
Differential Revision: https://phabricator.services.mozilla.com/D150980
Use the animation id from the stacking context to find the hit-testing tree node
for hit tests of elements that are sticky positioned. Then use this hit-testing
tree node reference to apply APZ transforms if the sticky positioned element is
stuck to the root content.
Differential Revision: https://phabricator.services.mozilla.com/D150047
## Summary
Pass the fixed position element animation id through webrender, returning the
the animation id in the hit-test result if the element is a fixed position
element. This animation id then can be used to lookup the relevant Hit-Testing
Tree Node, which can be used to find the fixed (or sticky) position side bits.
## Motivation
Sticky content can be currently stuck to the root content or not, based on the
scroll position. As a result, when hit testing sticky content, APZ needs both
the sticky position side bits and additional information to determine if the
element is currently stuck to the root content. This is needed to fix the
hit-testing of sticky position content when a APZ transform is being applied,
such as overscroll and hiding the dynamic toolbar.
## Implementation
The information needed to determine if a element is currently stuck to the root
content and the fixed/sticky position side bits is already stored in the
hit-testing tree node. Any hit test result should have a corresponding
hit-testing tree node entry. When a hit-test result contains a animation id and
a hit-testing tree node is found, we can store a pointer to this node and use
this to check the fixed/sticky position side bits. Something similar is already
done for hit test results when a scrollbar is hit.
Differential Revision: https://phabricator.services.mozilla.com/D148648
The `widget->DispatchInputEvent` codepath only works in gecko CI
configurations, so to allow this to be used for e.g. WebDriver
implement a path that doesn't go via the parent process.
Differential Revision: https://phabricator.services.mozilla.com/D150632
This removes the last piece of code in wrench and gecko (there is
one more callsite in WR itself) that relies on the legacy clip
parenting code.
Differential Revision: https://phabricator.services.mozilla.com/D150694
The `widget->DispatchInputEvent` codepath only works in gecko CI
configurations, so to allow this to be used for e.g. WebDriver
implement a path that doesn't go via the parent process.
Differential Revision: https://phabricator.services.mozilla.com/D150632
Add a way to define an item-local clip-chain from a series of
clips. Port a couple of tests to use this instead of relying on
legacy clip-parenting (which we plan to remove soon).
Differential Revision: https://phabricator.services.mozilla.com/D150662
However, also add a MOZ_ASSERT because GetGeckoContentControllerForRoot()
returning a RemoteContentController here is unexpected and should be
investigated further.
Differential Revision: https://phabricator.services.mozilla.com/D150638
Some more work towards removing the use of legacy clipid parenting
in wrench test files. Add support for specifying the spatial id
without also setting the clip parent. Port some more wrench tests
to use spatial-id and/or clip-chain.
Differential Revision: https://phabricator.services.mozilla.com/D150528
helper_bug982141 was the first APZ test to be run in its own window, a technique
which we've since formalized in runSubtestsSeriallyInFreshWindows().
Rather than having a dedicated test_bug982141 to open its window,
move the subtest into test_group_scrollframe_activation.
Differential Revision: https://phabricator.services.mozilla.com/D150609
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING is used on all platforms so let's use it on Linux too and don't add new feature for Linux only.
Differential Revision: https://phabricator.services.mozilla.com/D149765
The async front buffer posting is going to be enabled by another bug.
Async IPC was added for async front buffer posting for out-of-process WebGL.
Client does not use TextureClient for storing SurfaceDescriptor.
It works basically same way as to in-process WebGL around nsDisplayCanvas, WebRenderCanvasData, WebRenderCommandBuilder and WebRenderBridgeParent.
SharedSurfaces of SurfaceDescriptorD3D10 are kept alive during their usage. It is for keeping a shread handle valid.
Copied data buffers of SharedShurface_Basics are kept alive during their usage. It is for keeping RenderBufferTextureHost valid.
Differential Revision: https://phabricator.services.mozilla.com/D150197