Closed Bug 2092691 Opened 2 days ago Closed 2 days ago

GPU blit of a fenced MacIOSurface is skipped whenever waiting on its write fence succeeds

Categories

(Core :: Graphics, defect)

Desktop
macOS
defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr153 --- unaffected
firefox160 --- wontfix
firefox161 --- wontfix
firefox162 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 external file)

In GLBlitHelper::BlitSdToFramebuffer, the SurfaceDescriptorMacIOSurface case looks up the surface's write fence and does:

if (gpuFence && gpuFence->ServerWait(mGL, TimeDuration::Forever())) {
  return false;
}

GpuFenceMTLSharedEvent::ServerWait returns true on success (after inserting an eglWaitSync on the imported Metal shared event, or after its ClientWait fallback completes), as documented in GpuFence.h. So the blit bails out exactly when the wait works, and only goes ahead when both the server and client waits fail, i.e. when the surface may not be ready.

Before bug 2068875 the check was !sd.gpuFence()->ServerWait(...). The negation was lost when the fence lookup moved to CompositeProcessFencesHolderMap.

When the blit fails, TexUnpackSurface::BlitSd either falls back to a CPU readback (2D canvas uploads, allowFallback) or clears the texture to [0.2, 0.0, 0.2, 1.0] with a "Please file a bug!" warning.

This is latent today. The only fenced MacIOSurface I found reaching this code is a 2D canvas uploaded with texImage2D, exported via CanvasTranslator::WaitForSurface. There, BeginRead() drops the write fence first: SharedSurface_IOSurface inherits ProducerReadAcquireImpl -> ProducerAcquireImpl -> TakeAllFencesAndForget, and its ProducerReadReleaseImpl is empty. So GetWriteFence returns null by the time the blit runs. Confirmed with temporary logging on an M3 Pro (macOS 27): the descriptor carries a fencesHolderId but no write fence. That fence-dropping is a separate issue (the blit then runs without waiting for the export), but fixing it without this would make every 2D canvas -> WebGL blit on Metal ANGLE fail and fall back.

Fix: restore the negation, if (gpuFence && !gpuFence->ServerWait(...)) return false;.

The negation was lost in bug 2068875, so the blit bailed out whenever
GpuFence::ServerWait succeeded.

Set release status flags based on info from the regressing bug 2068875

Pushed by aosmond@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/df88730d2078 https://hg.mozilla.org/integration/autoland/rev/fd84ddf5f685 Blit fenced MacIOSurfaces only when waiting on the write fence succeeds. r=gfx-reviewers,jnicol
Status: ASSIGNED → RESOLVED
Closed: 2 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: