Closed Bug 1942232 Opened 29 days ago Closed 9 days ago

[Wayland] Make WaylandBuffer release more robust

Categories

(Core :: Widget: Gtk, defect, P3)

defect

Tracking

()

RESOLVED FIXED
137 Branch
Tracking Status
firefox137 --- fixed

People

(Reporter: stransky, Assigned: stransky)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

We need to make WaylandBuffer release more robust. It means:

  • Take lock for WaylandBuffer internal changes
  • Keep reference to WaylandSurface until WaylandBuffer is removed
  • Keep attached/detached state as an additional flag
  • Sync wl_buffer delete in case it's still attached to wl_surface

That ensures we don't release live buffers. Some of the work here is implemeneted at Bug 1743631.

Flags: needinfo?(stransky)
Flags: needinfo?(stransky)
Flags: needinfo?(stransky)
Duplicate of this bug: 1939713

Split WaylandBuffer attached state to two components:

  • Attached to WaylandSurface is tracked by mAttachedToSurface direct reference to WaylandSurface.
  • Attached to Wayland compositor (i.e. used by GPU) is tracked mIsAttachedToCompositor boolean flag.

Also change how wl_buffer is detached/deleted:

  • BufferDetachedCallbackHandler() only clear mIsAttachedToCompositor flag while WaylandBuffer is still valid.
  • BufferDeletedCallbackHandler() is used to clear wl_buffer when WaylandSurface is unmapped/deleted.

Such change ensures we keep references to WaylandSurface/WaylandBuffer pair even if WaylandBuffer is not recently used by GPU
and prevents early WaylandBuffer object delete.

Also add mutex tracking / debugging code to WaylandBuffer.

Assignee: nobody → stransky
Status: NEW → ASSIGNED

Allow to call AttachLocked() repeatedly for the same WaylandBuffer, it's used by widget code. Hold recently attached buffer by mAttachedBuffer
and all tracked buffers (attached but not released by compositor yet) at mTrackedBuffers.
It ensures we reference all buffers used by WaylandCompositor.

Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/2606acece21a [Wayland] Make WaylandBuffer release more robust r=emilio https://hg.mozilla.org/integration/autoland/rev/cd369e4db2ee [Wayland] Make WaylandSurface more robust r=emilio
Status: ASSIGNED → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
Regressions: 1943732
Regressions: 1943736
Regressions: 1943906

Backed out for causing Bug 1943732 and Bug 1943736

Status: RESOLVED → REOPENED
Flags: needinfo?(stransky)
Resolution: FIXED → ---
Target Milestone: 136 Branch → ---

Thanks, will rework it.

Attachment #9460503 - Attachment is obsolete: true
Attachment #9460504 - Attachment is obsolete: true
Flags: needinfo?(stransky)

WaylandBuffer detach/release can happen on various thread and races with WaylandSurface access to WaylandBuffer.
To ensure WaylandSurface/WaylandBuffer consistent state, manage WaylandBuffer via. WaylandSurface only.
Register all async callbacks to WaylandSurface and use WaylandSurfaceLock to access WaylandBuffer.

Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/f5e50c8e4669 [Wayland] Detach and Release WaylandBuffer through WaylandSurface only r=emilio

Updated, Thanks.

Flags: needinfo?(stransky)
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/88c7eaa3296d [Wayland] Detach and Release WaylandBuffer through WaylandSurface only r=emilio
Status: REOPENED → RESOLVED
Closed: 21 days ago9 days ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: