Open Bug 2097947 Opened 9 days ago Updated 12 hours ago

[Wayland][NVIDIA] Startup crash with GPU process + software WebRender: gbm_bo_create(RENDERING|LINEAR) fails, MOZ_CRASH(Fallback configurations exhausted)

Categories

(Core :: Graphics, defect)

x86_64
Linux
defect

Tracking

()

ASSIGNED

People

(Reporter: blargens, Assigned: bradwerth, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 2 external files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:162.0) Gecko/20100101 Firefox/162.0

Steps to reproduce

Reproduced on the official Nightly build: 163.0a1, BuildID 20261125210957, mozilla-central 5729c00d4cd8.

  1. Wayland session (KDE Plasma 6.8.3 / KWin) on an NVIDIA GPU, driver 620.73.04 (GBM backend nvidia).
  2. Create a fresh profile containing this user.js:
    user_pref("layers.gpu-process.enabled", true);
    user_pref("gfx.webrender.software", true);
    
  3. Run MOZ_LOG="Dmabuf:5" firefox --no-remote -profile <dir> about:blank

Actual results

Actual results

The parent process crashes with MOZ_CRASH(Fallback configurations exhausted) (exit 139) on every launch: about 3.2 s after start on Nightly, 1.4 s on 162.0b1. The GPU process can't allocate a single layer buffer:

[GPU: Renderer] D/Dmabuf DMABufDevice::OpenDRMFd() DRM device /dev/dri/renderD128
[GPU: Renderer] D/Dmabuf DMABufSurfaceRGBA::CreateGBM() UID … size 1024 x 512 format 0x34325241 modifiers 1
[GPU: Renderer] D/Dmabuf     Creating without modifiers
[GPU: Renderer] D/Dmabuf     Failed to create GbmBufferObject
…  (12× on Nightly, once per layer)
GraphicsCriticalError: [0]GP+[GFX1]: Failed to obtain buffer … | Handling webrender error 3
→ parent: MOZ_CRASH(Fallback configurations exhausted)

Full MOZ_LOG=Dmabuf:5 output from Nightly is attached.

Controls with clean profiles, each run for 25 s, give identical results on Nightly 163.0a1 and Developer Edition 162.0b1:

Profile prefs Result
layers.gpu-process.enabled=true + gfx.webrender.software=true crash, every launch
layers.gpu-process.enabled=false + gfx.webrender.software=true runs fine (parent uses SHM buffers)
layers.gpu-process.enabled=true (hardware WR) runs fine (GPU process uses DMABufSurfaceRGBA::CreateExport(), modifier 0x300000000e08014)

Troubleshoot Mode (safe mode) reproduces it too, because it forces software WebRender. That's how a real profile got stuck in a crash loop. A few GPU-process crashes (see "Related observation" below) led Firefox to offer Troubleshoot Mode, and Troubleshoot Mode then crashed within 1–5 s on every launch (6 consecutive crashes), all with GraphicsCriticalError: GP+[GFX1]: Failed to obtain buffer (t=0.66) | Handling webrender error 3.

Once bug 2095747 enables the Wayland GPU process by default, any NVIDIA user who lands in software WebRender (Troubleshoot Mode, the blocklist, or a hardware NEW_SURFACE error) will hit this on every startup.

Analysis

The relevant code is unchanged between 162.0b1 and mozilla-central 5729c00d4cd8.

  1. SurfacePoolWayland::ObtainBufferFromPool(): with no GL context in the GPU process, it calls WaylandBuffer::CreateMappableDMABuf() ("The parent process can only present DMABuf surfaces").

  2. DMABufSurfaceRGBA::CreateGBM(): the mappable path doesn't set DMABUF_USE_MODIFIERS, so it goes straight to the fallback:
    gbm_bo_create(dev, w, h, ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR)

  3. NVIDIA's GBM backend (620.73.04) rejects that flag combination. I tested it directly with libgbm on the same machine, which has both GPUs (script attached):

    1024×512 ARGB8888 NVIDIA renderD128 (backend nvidia) Intel renderD129 (Mesa drm)
    gbm_bo_create RENDERING|LINEAR (Firefox's call) FAIL OK
    gbm_bo_create LINEAR OK OK
    gbm_bo_create RENDERING OK OK
    create_with_modifiers2 [MOD_LINEAR], RENDERING FAIL OK
    create_with_modifiers2 [MOD_LINEAR], no flags OK OK

    A LINEAR-only BO on NVIDIA works for this use. gbm_bo_map(READ_WRITE) succeeds (stride 4096), CPU write and read-back work, and gbm_bo_get_fd() exports a dmabuf.

  4. So on NVIDIA the Wayland GPU process has no working software path. Whenever hardware WebRender gets disabled, the fallback chain dead-ends in gfxPlatform::FallbackFromAcceleration.

Possible fixes:

  • (a) Drop the RENDERING flag: for CPU-only mappable buffers, request GBM_BO_USE_LINEAR without GBM_BO_USE_RENDERING, or retry without it.
  • (b) Fall back to the parent: when the GPU process can't get software buffers, disable the GPU process and fall back to parent-process compositing instead of crashing.

Related observation: hardware path (cause unknown)

On my real profile (Developer Edition 162.0b1, GPU process + hardware WebRender, with the native compositor auto-enabled by layers.gpu-process.enabled), Firefox ran normally for about 13 minutes. Then the GPU process crashed with:

MOZ_DIAGNOSTIC_ASSERT(mInProgressBuffer) (NativeLayerWaylandRender: Failed to obtain buffer)

That assert is in NativeLayerWaylandSurfaceHandler::NextSurfaceAsFramebuffer(). It's fatal in Nightly and Developer Edition even though the next line handles a null buffer gracefully. After four GPU-process relaunches, hardware WebRender was disabled (FEATURE_FAILURE_WEBRENDER_NEW_SURFACE) and the software-path failure above finished it off. I don't know why that first hardware-path allocation failed. The kernel log has no NVRM errors at that time, and VRAM was mostly free (≈94 GB).

System

  • Firefox:
    • Nightly 163.0a1 (official build, BuildID 20261125210957).
    • Developer Edition 162.0b1 (CachyOS rebuild of Arch's package, build 20261124001945). Minidumps from the original crashes are available on request.
  • GPU: NVIDIA RTX PRO 6000 Blackwell (10de:2bb1), driver 620.73.04 (open kernel modules); egl-wayland 1.1.24, egl-wayland2 1.0.2, egl-gbm 1.1.4.
  • Second GPU: Intel Arrow Lake iGPU (8086:7d67) present but not driving displays; Mesa 26.3.1.
  • Desktop: KDE Plasma / KWin 6.8.3 (Wayland), Linux 7.3.6.
  • Displays: 2 × 3840×2160 outputs at scale 2, HDR enabled in KWin; gfx.color_management.hdr at its default (false).
  • Telemetry, 162 (crashing): gpuProcess: available, wrCompositor: available, compositor webrender_software at crash.
  • Telemetry, 161 (same prefs, no crash): gpuProcess: blocked:FEATURE_FAILURE_WAYLAND, wrCompositor: blocklisted:FEATURE_FAILURE_WEBRENDER_COMPOSITOR_DISABLED.

Expected results

Software WebRender in the Wayland GPU process should get a buffer. Failing that, Firefox should disable the GPU process and composite in the parent (SHM) instead of MOZ_CRASH.

Attachment #9691025 - Attachment description: Standalone libgbm test: RENDERING|LINEAR fails on NVIDIA, LINEAR → Standalone libgbm test: RENDERING|LINEAR fails on NVIDIA, LINEAR alone works
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

So on Mesa drivers I don't get a crash but still don't get working WebGL because:

  1. We don't request a dmabuf surface factory: https://searchfox.org/firefox-main/source/gfx/layers/CanvasRenderer.cpp#115
  2. Because the dmabuf implementation currently requires HW-WR: https://searchfox.org/firefox-main/source/widget/gtk/DMABufSurface.cpp#267-272

I think this can be fixed with bug 2097643, allowing us to allocate sysmem-backed dmabufs (essentially like shmem on steroids) with needing the the GL implementation.

Note, however, that the Nvidia situation around LINEAR might cause further mayhem - and we might need further workarounds (or help convince them to finally add support...).

See Also: → udmabuf
user_pref("gfx.webrender.software", true);

for SW-WR we need to create SHMBufSurface (and not dmabuf). That needs to be fixed in the GPU process code. The SHM surfaces can be transferred from GPU to content process as well. The only problem here is that wl_shm doesn't support import from shm fd so extra copy is required (unless udmabuf is implemented as Robert says).

(In reply to Robert Mader [:rmader] from comment #2)

Note, however, that the Nvidia situation around LINEAR might cause further mayhem - and we might need further workarounds (or help convince them to finally add support...).

I don't want to support it and we don't have a use case for it - we just use shm for SW rendering backends and dmabuf for HW ones. I primary target to HW and SW is juts a fallback so we may not invest much to a falback but rather make sure HW is well supported everywhere.

https://searchfox.org/firefox-main/rev/4de791e9c62b308a5ab1e4464dc1fd19d8c4d13b/gfx/layers/SurfacePoolWayland.cpp#138
That needs to be updated for SW rendering path, i.e. transfer shm surfaces from GPU process.

btw. we'd need to GPU process & SW backend for popups (if GPU process is used for them) as we don't use HW WR there.

Thanks, that makes sense. I'm looking into it right now.

for SW-WR we need to create SHMBufSurface (and not dmabuf).

My suggestion is to always use udmabuf if possible and fall back to shm otherwise. udmabuf is essentially shm but can avoid copies in a whole bunch of scenarios - however is only available on relatively recent distros (probably roughly those with proper Vulkan support).

I can reproduce this, without forcing SW-WR, by doing anything that causes a popup to appear (which, as of bug 2069150, by default includes selecting text); that causes the GPU process to call CreateGBM as described above. So, the “if” in comment #6 appears to be true.

Status: UNCONFIRMED → NEW
Ever confirmed: true

(In reply to Jed Davis [:jld] ⟨⏰|UTC-8⟩ ⟦he/him⟧ from comment #8)

I can reproduce this, without forcing SW-WR, by doing anything that causes a popup to appear (which, as of bug 2069150, by default includes selecting text); that causes the GPU process to call CreateGBM as described above. So, the “if” in comment #6 appears to be true.

The fix may be trivial - just transfer shm over IPC bridge, we have that alerady implemented, I guess AI can create such patch. I can look at it if needed.

Flags: needinfo?(stransky)

This lets shared memory surfaces be tracked across processes the same way
DMABuf surfaces are. No behavior change.

This is an altnerative to mappable DMABufs, which aren't available on
NVIDIA. These shmems are included in the NativeLayerRemote protocol as
another type of surface descriptor. NativeLayerRemoteWayland is changed
to send either type of buffer, and NativeLayerRootRemoteWaylandParent is
changed to receive either type.

Assignee: nobody → bwerth
Status: NEW → ASSIGNED

(In reply to Martin Stránský [:stransky] (ni? me) from comment #9)

The fix may be trivial - just transfer shm over IPC bridge, we have that alerady implemented, I guess AI can create such patch. I can look at it if needed.

I made an attempt at this approach, uploaded the patches. Claude notes that the increased use of SHMBufSurfaceRGBA will trigger frequent calls to wl_shm_pool, which is a potential performance problem. I'm happy to have :rmader or :stransky take the Bug and commandeer these patches; I claim no special insight into the problems and solutions you have both identified thus far.

Brad, will look at it. At the first look the patch is a bit over-complicated. The wl_shm and shm memcopy may be bottleneck but IMHO we don't care - it's used for tiny popups/tooltips only and similar things. Large popups can use HW-WR and we even can flip all popups to HW-WR is necessary or update the popup size used to SW-WR etc.

SW-WR is slow regardless so so need to care about optimize. The dmabuf ref-counting is used for dmabuf video frame recycle, I think we can just copy shm or use the same mechanism we have for shm textures.

Anyway, looks like my fault as I overlooked the gl windowless dmabuf creation in the initial GPU process patch - it's known to be broken. Sorry for that.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: