Closed Bug 1844543 Opened 2 years ago Closed 2 years ago

nsWindow::SetEGLNativeWindowSize() and nsWindow::GetNativeData(NS_NATIVE_EGL_WINDOW) is not thread safe

Categories

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

defect

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox-esr115 - wontfix
firefox119 --- fixed

People

(Reporter: stransky, Assigned: stransky)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 5 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

nsWindow::SetEGLNativeWindowSize() and nsWindow::GetNativeData(NS_NATIVE_EGL_WINDOW) may be called from Renderer thread and need sync with Main thread.

Flags: needinfo?(stransky)
Assignee: nobody → stransky
Status: NEW → ASSIGNED

Move EGLWindow resize code from nsWindow to MozContainerWayland. It allows to use container lock and make the operation thread safe.

Depends on D184121

If GdkCeiledScaleFactor() is called from non-main thread (compositor, renderer etc.) just return recent scale factor and don't update it. If it's changed it will be updated from main thread later.

Depends on D184122

Remove hidden GdkCeiledScaleFactor() call from moz_container_wayland_set_scale_factor_locked() and pass it directly there.
It reduces number of GdkCeiledScaleFactor() calls and make sure scale is not changed surprisingly.

G: changed widget/gtk/WindowSurfaceWaylandMultiBuffer.cpp

Depends on D184123

Attachment #9344875 - Attachment is obsolete: true
Attachment #9344874 - Attachment is obsolete: true

Remove hidden GdkCeiledScaleFactor() call from moz_container_wayland_set_scale_factor_locked() and pass it directly there.
It reduces number of GdkCeiledScaleFactor() calls and make sure scale is not changed surprisingly.

Depends on D184122

GdkCeiledScaleFactor() can't be called from non-main thread (compositor, renderer etc.).
In such case just return recent scale factor and don't update it.
If it's changed it will be updated from main thread later.

Depends on D184170

Flags: needinfo?(stransky)
Duplicate of this bug: 1826684
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/989758821905 [Wayland] Add more scale changes logging r=emilio
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/114fe5b2c6dd [Wayland] Implement EGL size changes in MozContainer r=emilio https://hg.mozilla.org/integration/autoland/rev/6c1f22c273b9 [Wayland] Pass window scale to moz_container_wayland_set_scale_factor_locked() directly r=emilio https://hg.mozilla.org/integration/autoland/rev/f19933e3f455 [Wayland] Use nsWindow::GetCachedCeiledScaleFactor() to get scale factor from renderer/conpositor thread r=emilio https://hg.mozilla.org/integration/autoland/rev/8dbafcdb0be7 [Linux] Use mutex to ensure thread safe nsWindow destroy r=emilio
Flags: needinfo?(stransky)
Keywords: leave-open
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/91e48d264a62 [Wayland] Implement EGL size changes in MozContainer r=emilio https://hg.mozilla.org/integration/autoland/rev/3b42c79afd36 [Wayland] Pass window scale to moz_container_wayland_set_scale_factor_locked() directly r=emilio https://hg.mozilla.org/integration/autoland/rev/1a4518e0602b [Wayland] Use nsWindow::GetCachedCeiledScaleFactor() to get scale factor from renderer/conpositor thread r=emilio https://hg.mozilla.org/integration/autoland/rev/4921cebd7db4 [Linux] Use mutex to ensure thread safe nsWindow destroy r=emilio

Backed out for causing multiple failures on Linux WebRender

Flags: needinfo?(stransky)
Duplicate of this bug: 1847291
Flags: needinfo?(stransky)
Keywords: leave-open
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/8552ae037335 [Wayland] Implement EGL size changes in MozContainer r=emilio https://hg.mozilla.org/integration/autoland/rev/d37d5b5058f2 [Wayland] Pass window scale to moz_container_wayland_set_scale_factor_locked() directly r=emilio https://hg.mozilla.org/integration/autoland/rev/aa3cdac16780 [Wayland] Use nsWindow::GetCachedCeiledScaleFactor() to get scale factor from renderer/conpositor thread r=emilio
Attachment #9344963 - Attachment is obsolete: true

We need to use test&set atomic operation and not mutex.

https://hg.mozilla.org/mozilla-central/rev/aa3cdac16780 is causing Assertion failure: NS_IsMainThread(), at mozilla-central/widget/gtk/nsWindow.cpp:8900 for me on startup on sway.
So I can't start devel-builds right now with this change.

Flags: needinfo?(stransky)
Regressions: 1850667
Flags: needinfo?(stransky)
Attachment #9350619 - Attachment is obsolete: true
Attachment #9350618 - Attachment is obsolete: true
See Also: → 1849662
Regressions: 1850654
Pushed by stransky@redhat.com: https://hg.mozilla.org/integration/autoland/rev/5378e223b13e [Linux] Use mutex to ensure thread safe nsWindow destroy r=emilio

Last patches landed, closing.

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Keywords: leave-open
Resolution: --- → FIXED
See Also: → 1850285
See Also: → 1863425

[Tracking Requested - why for this release]: Could we consider backporting this to ESR115? Especially the thread-safety fix for nsWindow.

Sounds like a question for Martin. It'd need a rebased patch if yes.

Flags: needinfo?(stransky)
Target Milestone: --- → 119 Branch

Tom, could you clarify why for comment 27? Not a lot of context there :)

Flags: needinfo?(tschuster)

(In reply to Tom Schuster (MoCo) from comment #27)

[Tracking Requested - why for this release]: Could we consider backporting this to ESR115? Especially the thread-safety fix for nsWindow.

We'd need to backport all the patches here. Not sure how much work is that.

Flags: needinfo?(stransky)
Flags: needinfo?(tschuster)

From what I can see, the patches in this bug do not all graft cleanly. I wouldn't be opposed to taking a rebased set of patches for ESR if the belief is that they help with some crashes tracked in other bugs, but we'll need those to be posted with approval requests for that to be considered.

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

Attachment

General

Created:
Updated:
Size: