Closed Bug 2096020 Opened 4 days ago Closed 3 days ago

Each browser window with the custom titlebar leaks ~20 GDI objects through the Windows App SDK title bar, until the process hits the GDI quota

Categories

(Core :: Widget: Win32, defect)

defect

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox163 --- fixed

People

(Reporter: florian, Assigned: florian)

References

(Regressed 1 open bug)

Details

Attachments

(1 external file)

On Windows 11, every browser window that uses the custom titlebar leaves about 20 GDI objects behind in the parent process when it is closed: about 10 memory DCs and 10 32-bpp DIB sections. nsWindow::SetCustomTitlebar calls WindowsUIUtils::SetIsTitlebarCollapsed(mWnd, true), which makes the Windows App SDK extend its title bar into the client area, and nsWindow::Destroy never undoes it. The objects survive DestroyWindow and memory minimization. They aren't created by Firefox code: hooks on the GDI syscalls of the parent's main thread, with native stacks, see none of them.

Windows allows 10,000 GDI objects per process. A session that opens about 500 windows reaches the limit, and the parent dies with exit code 0xE0464645 (a fail-fast, so no crash report). That is what happens to the aiwindow browser-chrome tests on the Windows 11 25H2 shippable repeat jobs: browser_smartwindow_switcher_telemetry.js and browser_sidebar_aiwindow.js are the tests running when the limit is reached.

On try, windows with the native titlebar or with widget.windows.windowsappsdk.enabled=false don't leak. Resetting the SDK title bar (SetIsTitlebarCollapsed(mWnd, false), i.e. ResetToDefault) before DestroyWindow brings the leak from 20 per window to 0. The patch does that in nsWindow::Destroy.

See Also: → 2000475
Pushed by fqueze@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b6c0803e6614 https://hg.mozilla.org/integration/autoland/rev/eeb70c96e27e Reset the Windows App SDK title bar before destroying a window to release its GDI objects, r=win-reviewers,gstoll.
Pushed by fqueze@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8d36900d22d5 https://hg.mozilla.org/integration/autoland/rev/5f8d2f008e40 Reset the Windows App SDK title bar before destroying a window to release its GDI objects, r=win-reviewers,gstoll.
Status: ASSIGNED → RESOLVED
Closed: 3 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
See Also: → 2096461

Is there a realistic scenario for users hitting this in the wild, or is it mainly something long test runs run into? For example, is the fail-fast crash in bug 2000475 this leak?

(In reply to Ryan VanderMeulen [:RyanVM] from comment #6)

Is there a realistic scenario for users hitting this in the wild

It crashes when opening the ~500th browser window with tabs in the title bar. So maybe some users with very long sessions opening and closing multiple windows a day? It doesn't explain bug 2000475.

Flags: needinfo?(florian)
Regressions: 2097506
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: