Closed Bug 2031249 Opened 1 month ago Closed 13 days ago

Intermitent tests | application crashed [@ -[NSApplication _crashOnException:]] Crashing on exception: *** Collection <__NSArrayM: 0x13d787820> was mutated while being enumerated

Categories

(Firefox Enterprise :: Client, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: intermittent-bug-filer, Assigned: vlopezgarcia)

References

Details

(Keywords: crash, intermittent-failure, intermittent-testcase, Whiteboard: [collect_confirm_failure])

Crash Data

Attachments

(8 files)

Summary: Intermittent E64983C9-DFD0-4D7A-BBF8-B39CCCC3026C | single tracking bug → TEST-UNEXPECTED-ERROR | testing/enterprise/test_felt_browser_rapid_new_windows_from_cli.py FeltRapidNewWindowsFromCli.test_new_window_from_cli
Attached file log

(In reply to vlopezgarcia from comment #2)

There is a crash in here

https://treeherder.mozilla.org/logviewer?job_id=559648857&repo=enterprise-firefox-pr&task=T4DSj2EqQ9aimRjPPkjyIA.0&lineNumber=11130
https://treeherder.mozilla.org/logviewer?job_id=559648857&repo=enterprise-firefox-pr&task=T4DSj2EqQ9aimRjPPkjyIA.0&lineNumber=11167

https://tests.firefox.dev/crash-viewer.html?url=https%3A%2F%2Ffirefox-ci-tc.services.mozilla.com%2Fapi%2Fqueue%2Fv1%2Ftask%2FT4DSj2EqQ9aimRjPPkjyIA%2Fruns%2F0%2Fartifacts%2Fpublic%2Ftest_info%2FE64983C9-DFD0-4D7A-BBF8-B39CCCC3026C.json

Maybe related to https://github.com/mozilla/enterprise-firefox/pull/687

Do you see anything remotely related to the this.dockSupport call in the stack?

[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - Crash reason:  EXC_BREAKPOINT / EXC_ARM_BREAKPOINT
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - Crash address: 0x000000019c30af5c
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - Mac Crash Info:
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO -   Record 0
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO -     module: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO -     message: Crashing on exception: *** Collection <__NSArrayM: 0x13d787820> was mutated while being enumerated.
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO -     backtrace: 0   CoreFoundation                      0x0000000198532e80 __exceptionPreprocess + 176
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 1   libobjc.A.dylib                     0x000000019801acd8 objc_exception_throw + 88
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 2   CoreFoundation                      0x00000001985d9c34 -[__NSSingleObjectEnumerator init] + 0
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 3   AppKit                              0x000000019c0dacac NSViewUpdateVibrancyForSubtree + 192
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 4   AppKit                              0x000000019c0dacb8 NSViewUpdateVibrancyForSubtree + 204
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 5   AppKit                              0x000000019c0dacb8 NSViewUpdateVibrancyForSubtree + 204
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 6   AppKit                              0x000000019c0daaf8 -[NSWindow displayIfNeeded] + 160
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 7   AppKit                              0x000000019c0da9cc __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 520
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 8   AppKit                              0x000000019c0d98fc NSDisplayCycleObserverInvoke + 168
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 9   AppKit                              0x000000019c0d955c NSDisplayCycleFlush + 672
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 10  QuartzCore                          0x00000001a10038d0 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 120
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 11  QuartzCore                          0x00000001a1002638 _ZN2CA11Transaction6commitEv + 320
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 12  AppKit                              0x000000019c159a9c __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 272
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 13  AppKit                              0x000000019cb648f4 ___NSRunLoopObserverCreateWithHandler_block_invoke + 64
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 14  CoreFoundation                      0x00000001984bfbe8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 15  CoreFoundation                      0x00000001984bfad4 __CFRunLoopDoObservers + 552
[task 2026-04-13T09:18:08.258+00:00] 09:18:08     INFO - 16  CoreFoundation                      0x00000001984bf104 __CFRunLoopRun + 788
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 17  CoreFoundation                      0x00000001984be734 CFRunLoopRunSpecific + 588
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 18  HIToolbox                           0x00000001a3a2d530 RunCurrentEventLoopInMode + 292
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 19  HIToolbox                           0x00000001a3a33348 ReceiveNextEventCommon + 676
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 20  HIToolbox                           0x00000001a3a33508 _BlockUntilNextEventMatchingListInModeWithFilter + 76
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 21  AppKit                              0x000000019c036848 _DPSNextEvent + 660
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 22  AppKit                              0x000000019c99cc24 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 23  XUL                                 0x000000014a940ea0 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 160
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 24  AppKit                              0x000000019c029874 -[NSApplication run] + 480
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 25  XUL                                 0x000000014a940d38 -[GeckoNSApplication run] + 72
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 26  XUL                                 0x000000014a9423f0 _ZN10nsAppShell3RunEv + 664
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 27  XUL                                 0x000000014b956160 _ZN12nsAppStartup3RunEv + 136
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 28  XUL                                 0x000000014bad85ec _ZN7XREMain11XRE_mainRunEv + 5080
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 29  XUL                                 0x000000014bada3c4 _ZN7XREMain8XRE_mainEiPPcRKN7mozilla15BootstrapConfigE + 3224
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 30  XUL                                 0x000000014badb018 _Z8XRE_mainiPPcRKN7mozilla15BootstrapConfigE + 192
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 31  firefox                             0x0000000100950c14 main + 888
[task 2026-04-13T09:18:08.259+00:00] 09:18:08     INFO - 32  dyld                                0x0000000198058274 start + 2840

Would you have ideas what is triggering this? From the stack, it's not directly our code

Flags: needinfo?(spohl.mozilla.bugs)
Flags: needinfo?(haftandilian)

Victor, do you have been able to repro locally, or only on CI? Can you share STR to help others investigat?

Flags: needinfo?(vlopezgarcia)

(In reply to :gerard-majax from comment #5)

Victor, do you have been able to repro locally, or only on CI? Can you share STR to help others investigat?

I have seen it only in CI

Flags: needinfo?(vlopezgarcia)

(In reply to vlopezgarcia from comment #6)

(In reply to :gerard-majax from comment #5)

Victor, do you have been able to repro locally, or only on CI? Can you share STR to help others investigat?

I have seen it only in CI

How frequently, do you have an idea?

(In reply to :gerard-majax from comment #7)

(In reply to vlopezgarcia from comment #6)

(In reply to :gerard-majax from comment #5)

Victor, do you have been able to repro locally, or only on CI? Can you share STR to help others investigat?

I have seen it only in CI

How frequently, do you have an idea?

I have seen it twice, the other occurrence in here (although this was my PR with a bunch of changes, it shows the same stack). The other one discussed above is a clean PR.

https://treeherder.mozilla.org/logviewer?job_id=559479997&repo=enterprise-firefox-pr&task=AjsM1M2aQZuasD_mybniUg.0&lineNumber=843

I am not sure how often it happens, maybe 1/200.

The info I have is it looks like it happen in very early startup,

To your question

Do you see anything remotely related to the this.dockSupport call in the stack?

We added the line not so long ago, and it interacts with AppKit, but it is just a guess.

Is it safe to call this early on startup??
https://searchfox.org/enterprise-main/rev/4b4e7c59db50500302fa0e437ee07a84d92aa076/widget/nsIMacDockSupport.idl#36-45

(In reply to vlopezgarcia from comment #8)

Is it safe to call this early on startup??
https://searchfox.org/enterprise-main/rev/4b4e7c59db50500302fa0e437ee07a84d92aa076/widget/nsIMacDockSupport.idl#36-45

How early are we talking about? It shouldn't be called before applicationDidFinishLaunching:.

Flags: needinfo?(spohl.mozilla.bugs)
Flags: needinfo?(haftandilian)

(In reply to :gerard-majax from comment #10)

https://searchfox.org/enterprise-main/rev/8ad7bae3daf8c761d6611955fb03602820ef04a3/browser/base/content/nonbrowser-mac.js#163

So since it's called when we receive the load event, I would assume applicationDidFinishLaunching was called, but I have not verified

Authored by https://github.com/victhorlopez
https://github.com/mozilla/enterprise-firefox/commit/b38a1b389382b925dd5983afd824ba6f1fca6529
[enterprise-main] Bug 2031249: Move activate application when the window is loaded (same pattern as nonbrowser-mac.js) (#727) r=lissyx

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached file log_ci_with_traces

Summary, after adding some traces I managed to get some info on what is mutated.

[task 2026-04-28T09:07:03.777+00:00] 09:07:03     INFO -  FELT_TITLEBAR_BEFORE count=7: NSVisualEffectView(0x11a195600) NSView(0x11a194100) NSTextField(0x11d27b400) NSView(0x11a195000) _NSThemeCloseWidget(0x11c473900) _NSThemeZoomWidget(0x104a69200) _NSThemeWidget(0x104a6aa00)
[task 2026-04-28T09:07:03.777+00:00] 09:07:03     INFO -  FELT_TITLEBAR_AFTER  count=8: NSVisualEffectView(0x11a195600) NSView(0x11a194100) NSTextField(0x11d27b400) NSView(0x11a195000) _NSThemeCloseWidget(0x11c473900) _NSThemeZoomWidget(0x104a69200) _NSThemeWidget(0x104a6aa00) _NSThemeFullScreenButton(0x11a190c00)

It looks like when it crashes a _NSThemeFullScreenButton is added while items are enumerated.

I added swizzle on the titlebar function, this is the appkit callstack that adds the button

[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    0   XUL                                 0x000000014411c750 _ZL26SwizzledTitlebarAddSubviewP11objc_objectP13objc_selectorP6NSView + 284
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    1   AppKit                              0x00000001a10ba350 -[NSThemeFrame addTitlebarSubview:] + 80
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    2   AppKit                              0x00000001a10b3084 -[NSThemeFrame _updateButtons] + 884
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    3   AppKit                              0x00000001a10b4634 -[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] + 564
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    4   AppKit                              0x00000001a10b3acc -[NSWindow _effectiveCollectionBehavior] + 492
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    5   AppKit                              0x00000001a10b38ac -[NSWindow(NSFullScreen) canEnterFullScreenMode] + 16
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    6   AppKit                              0x00000001a10b3860 -[NSWindow showsFullScreenButton] + 24
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    7   AppKit                              0x00000001a1134060 -[_NSThemeWidgetCell coreUIWidgetType] + 228
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    8   AppKit                              0x00000001a1133e48 -[_NSThemeWidgetCell coreUIDrawOptionsInView:isFlipped:] + 60
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    9   AppKit                              0x00000001a1133dc4 -[_NSThemeWidgetCell _vibrancyBlendModeForControlView:] + 52
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    10  AppKit                              0x00000001a1132eac -[NSControl _vibrancyBlendMode] + 40
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    11  AppKit                              0x00000001a1b7850c -[NSView _vibrancyFilter] + 16
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    12  AppKit                              0x00000001a1b78660 __34-[NSView _effectiveVibrancyFilter]_block_invoke + 44
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    13  AppKit                              0x00000001a107e238 +[NSAppearance _performWithCurrentAppearance:usingBlock:] + 72
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    14  AppKit                              0x00000001a1b785e8 -[NSView _effectiveVibrancyFilter] + 196
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    15  AppKit                              0x00000001a1b78694 -[NSView _updateVibrancy] + 24
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    16  AppKit                              0x00000001a1132c3c NSViewUpdateVibrancyForSubtree + 80
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    17  AppKit                              0x00000001a1132cb8 NSViewUpdateVibrancyForSubtree + 204
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    18  AppKit                              0x00000001a1132cb8 NSViewUpdateVibrancyForSubtree + 204
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    19  AppKit                              0x00000001a1132cb8 NSViewUpdateVibrancyForSubtree + 204
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    20  AppKit                              0x00000001a1132af8 -[NSWindow displayIfNeeded] + 160
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    21  XUL                                 0x00000001441050b4 -[BaseWindow displayIfNeeded] + 184
[task 2026-04-28T09:07:03.773+00:00] 09:07:03     INFO -    22  AppKit                              0x00000001a11329cc __NSWindowGetDisplayCycleObserverForDisplay_block_invoke + 520

Simplified, it looks like what it happens is

 NSViewUpdateVibrancyForSubtree          ← enumerating titlebar subviews
    → [NSView _updateVibrancy]
      → [NSView _effectiveVibrancyFilter]
        → [_NSThemeWidgetCell _vibrancyBlendModeForControlView:]
          → [_NSThemeWidgetCell coreUIDrawOptionsInView:]
            → [_NSThemeWidgetCell coreUIWidgetType]
              → [NSWindow showsFullScreenButton]
                → [NSWindow canEnterFullScreenMode]
                  → [NSWindow _effectiveCollectionBehavior]
                    → [NSWindow _cacheAndSetPropertiesForCollectionBehavior:]
                      → [NSThemeFrame _updateButtons]        ← DECIDES TO ADD THE BUTTON
                        → [NSThemeFrame addTitlebarSubview:]
                          → [NSTitlebarView addSubview:]     ← MUTATES THE ARRAY

This happens in CI 1 or 2 every 50 runs in debug with "macOS 15.3 (24D60)"

Filtering for nsview shows the title bar only has once this button, which suggest there is a race somewhere and MacOS uses some default value and decides to create a _NSThemeFullScreenButton

...
[task 2026-04-28T09:06:06.293+00:00] 09:06:06     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x15b9f6a00) NSView(0x15b9f8b00) NSTextField(0x15b980800) NSView(0x15b9f7f00) _NSThemeCloseWidget(0x13d05a600) _NSThemeZoomWidget(0x1598ebd00) _NSThemeWidget(0x12286c300)
[task 2026-04-28T09:06:30.887+00:00] 09:06:30     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x13e04e600) NSView(0x13e04e000) NSTextField(0x15a9bb800) NSView(0x13e050400) _NSThemeCloseWidget(0x15cace100) _NSThemeZoomWidget(0x13e04ec00) _NSThemeWidget(0x13e050100)
[task 2026-04-28T09:06:41.667+00:00] 09:06:41     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x11ac46400) NSView(0x11ac43100) NSTextField(0x15df93400) NSView(0x11ac44300) _NSThemeCloseWidget(0x15b4aeb00) _NSThemeZoomWidget(0x11c32ca00) _NSThemeWidget(0x15b78fd00)
[task 2026-04-28T09:06:48.972+00:00] 09:06:48     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x13d011800) NSView(0x13d011500) NSTextField(0x13f7ad000) NSView(0x13d012100) _NSThemeCloseWidget(0x15d5ba700) _NSThemeZoomWidget(0x13d00f400) _NSThemeWidget(0x13d010c00)
[task 2026-04-28T09:06:49.464+00:00] 09:06:49     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x140956100) NSView(0x140959700) NSTextField(0x143f9b000) NSView(0x140958e00) _NSThemeCloseWidget(0x1410b0a00) _NSThemeZoomWidget(0x14095ea00) _NSThemeWidget(0x143fb0400)
[task 2026-04-28T09:07:02.652+00:00] 09:07:02     INFO -  FELT_TITLEBAR_HEALTHY count=7: NSVisualEffectView(0x14fb72d00) NSView(0x14fb75d00) NSTextField(0x151cc9c00) NSView(0x14fb73600) _NSThemeCloseWidget(0x1529eac00) _NSThemeZoomWidget(0x14fb72700) _NSThemeWidget(0x14fb74b00)
[task 2026-04-28T09:07:03.777+00:00] 09:07:03     INFO -  FELT_TITLEBAR_BEFORE count=7: NSVisualEffectView(0x11a195600) NSView(0x11a194100) NSTextField(0x11d27b400) NSView(0x11a195000) _NSThemeCloseWidget(0x11c473900) _NSThemeZoomWidget(0x104a69200) _NSThemeWidget(0x104a6aa00)
[task 2026-04-28T09:07:03.777+00:00] 09:07:03     INFO -  FELT_TITLEBAR_AFTER  count=8: NSVisualEffectView(0x11a195600) NSView(0x11a194100) NSTextField(0x11d27b400) NSView(0x11a195000) _NSThemeCloseWidget(0x11c473900) _NSThemeZoomWidget(0x104a69200) _NSThemeWidget(0x104a6aa00) _NSThemeFullScreenButton(0x11a190c00)
[task 2026-04-28T09:07:03.777+00:00] 09:07:03     INFO -  FELT_MUTATED_ARRAY count=8: NSVisualEffectView(0x11a195600) NSView(0x11a194100) NSTextField(0x11d27b400) NSView(0x11a195000) _NSThemeCloseWidget(0x11c473900) _NSThemeZoomWidget(0x104a69200) _NSThemeWidget(0x104a6aa00) _NSThemeFullScreenButton(0x11a190c00)
...
Assignee: nobody → vlopezgarcia
Summary: TEST-UNEXPECTED-ERROR | testing/enterprise/test_felt_browser_rapid_new_windows_from_cli.py FeltRapidNewWindowsFromCli.test_new_window_from_cli → Intermitent tests | application crashed [@ -[NSApplication _crashOnException:]] Crashing on exception: *** Collection <__NSArrayM: 0x13d787820> was mutated while being enumerated

I did some more research, usually the window creation steps are

  1. Create window with some flags
  2. Appkit calls displayIfNeeded
  3. XUL Parsing, sets some attributes

Internally the function _implicitlyAllowsFullScreenPrimary gets called to decide if the window can be fullscreen. This function in our setup looks like is non-deterministic when _NXIsBackgroundOnly=YES. With identical observable window properties (bgOnly=1, isTitled=1, isResizable=1, isSheet=0, level=0), the function returns result=1 on some calls and result=0 on others, if this behaviour happens inside the first displayIfNeeded calls, it can cause the crash.

From the swizzle trace on the crashing window 0x16593af00:

# During initWithContentRect and first displayIfNeeded result=1 (stable)                                                                                                
FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=1 bgOnly=1 ...                                                                                                
FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=1 bgOnly=1 ...                                                                                                
 → ecb=0x8a4 (has FullScreenPrimary 0x80 from implicit path)                                                                                                             
                                                                                                                                                                         
# During second displayIfNeeded result FLIPS to 0                                                                                                                       
FELT_ECB displayIfNeeded.enter    window=0x16593af00 cb=0x0 ecb=0x8a4 HAS_PRIMARY                                                                                         
FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=0 bgOnly=1 ...                                                                                                
 → ecb changes to 0x80a4 (0x8000 bit added, FullScreenPrimary drops to button heuristic path)
 → _cacheAndSetPropertiesForCollectionBehavior detects change                                                                                                            
 → _updateButtons called                                                                                                                                                 
 → _NSThemeFullScreenButton added to NSTitlebarView                                                                                                                      
 → CRASH: array mutated during NSViewUpdateVibrancyForSubtree enumeration  

I have been trying to trace whether some enterprise code is causing this, I thought it was actually our special LSUIElement setup in here and here but turns out without that the issue also shows up.

I am currently checking if setting LSUIElement could make this unstable.
edit: Just checked and without

#ifdef MOZ_ENTERPRISE
	<key>LSUIElement</key>
	<true/>
#endif

the issue also happens.

My proposed change would be to add something similar to this diff below, to prevent to go into the unstable function _implicitlyAllowsFullScreenPrimary

diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm                                                                                                
  --- a/widget/cocoa/nsCocoaWindow.mm                                                                                                                                       
  +++ b/widget/cocoa/nsCocoaWindow.mm                                                                                                                                       
  @@ @@                                                                                                                                                                     
     } else {                                                                                                                                                               
       // Non-popup windows are always opaque.                                                                                                                              
       mWindow.opaque = YES;
  +
  +    if (mWindowType == WindowType::TopLevel &&
  +        (features & NSWindowStyleMaskTitled)) {
  +      mWindow.collectionBehavior = mWindow.collectionBehavior |                                                                                                          
  +                                   NSWindowCollectionBehaviorFullScreenPrimary;
  +    }                                                                                                                                                                    
     }   

Do you know if setting the above diff could cause issues? usually this attribute is read later on from XUL

Flags: needinfo?(mstange.moz)
Attached file crash.log with traces
Crash Signature: [@ -[NSApplication _crashOnException:]] → [@ NSViewUpdateVibrancyForSubtree]

I will reiterate on what I have seen ( or my understanding) and why I did this PR

0x000000014411c750 _ZL26SwizzledTitlebarAddSubviewP11objc_objectP13objc_selectorP6NSView + 284
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    1   AppKit                              0x00000001a10ba350 -[NSThemeFrame addTitlebarSubview:] + 80
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    2   AppKit                              0x00000001a10b3084 -[NSThemeFrame _updateButtons] + 884
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    3   AppKit                              0x00000001a10b4634 -[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] + 564
[task 2026-04-28T09:07:03.772+00:00] 09:07:03     INFO -    4   AppKit                              0x00000001a10b3acc -[NSWindow _effectiveCollectionBehavior] + 492

From this trace basically we want to prevent the calls that happen to add the subview.

[NSThemeFrame _updateButtons]
[NSThemeFrame addTitlebarSubview:] 

Here the relevant lines before the crash from the attached log in the bugzilla

[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_ECB displayIfNeeded.enter                         window=0x16593af00 cb=0x0 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=0 bgOnly=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x129575820 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=0 bgOnly=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x129575820 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_CURRENTLY_ALLOWS_FS window=0x16593af00 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_CACHE_SET_CB window=0x16593af00 cb=0x80a4 windowNum=-1
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=0 bgOnly=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x129575820 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_IMPLICITLY_ALLOWS_FS_PRIMARY window=0x16593af00 result=0 bgOnly=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x129575820 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_CURRENTLY_ALLOWS_FS window=0x16593af00 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_CACHE_SET_CB window=0x16593af00 cb=0x80a4 windowNum=-1

result here means what the function _implicitlyAllowsFullScreenPrimary is giving as result, we can see when we go inside displayIfNeeded.enter the function evaluates to 0 (when previously was always 1). ECB means, "effectiveCollectionBehaviour", notice this ECB is the actual computed value internally by Appkit, not the flag we set.

As we can see the flag goes from 0x8a4 to 0x80a4.

[task 2026-05-07T08:01:01.948+00:00] 08:01:01     INFO -  FELT_CACHE_SET_CB window=0x16593af00 cb=0x80a4 windowNum=-1

This log in here is for FELT_CACHE_SET_CB _cacheAndSetPropertiesForCollectionBehavior internally it is setting 0x80a4

This means there is an internal change, because of this change in the middle of enumeration the function is triggering some side effects that are leading to the crash(adding a view)

The PR prevents the function call _implicitlyAllowsFullScreenPrimary inside effectiveCollectionBehaviour (and some more code inside the if) that looks like is changing this flag unexpectedly. When the flag remains stable the function _cacheAndSetPropertiesForCollectionBehavior is called without creating side effects.

Looking at when _implicitlyAllowsFullScreenPrimary is called, it seems we can avoid the call to it entirely if we pick an explicit collection behavior for both fullscreen (primary vs auxiliary) and tiling (allow vs disallow).

We already have calls to SetSupportsNativeFullScreen. I think we should make it so that:

  1. If called with true: Use NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorFullScreenAllowsTiling
  2. If called with false: Use NSWindowCollectionBehaviorFullScreenAuxiliary | NSWindowCollectionBehaviorFullScreenDisallowsTiling

Can you investigate this approach?

Flags: needinfo?(mstange.moz) → needinfo?(vlopezgarcia)

As discussed, the XUL parsing happens after the first display.
I will do the changes to have both flags by default in all paths, and modify the function SetSupportsNativeFullScreen to also set both flags applied.

Flags: needinfo?(vlopezgarcia)
Attached file local.log

I checked, the attached log "local.log" has 3 windows.
0x13cf2ca00 InvisibleWindow
0x15ccd7c00 ToolbarWindow
0x162149c00 TUINSWindow (no idea what this one is)

In general it looks good, it has only one detail. We set the flags not on the very early creation steps, that means appkit uses 0x0 as collectionBehaviour initially and relies on _implicitlyAllowsFullScreenPrimary.

The log shows some calls very early on, but they are outside of display calls, I would consider this safe as long we are stable on display.

FELT _implicitlyAllowsFullScreenPrimary window=0x15ccd7c00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x134889580 frame=1x33 aux105=0 aux102=0x0

By the end of CreateNativeWindow.end we already have cb=0x880, after that no calls to _implicitlyAllowsFullScreenPrimary on the same window pointer

I did one last test to verify the change is working, cause the above test was done locally, this was just a run to compare the calls on the CI with the changes setting the flags and without them.

teststart_withoutchanges_ci_macos153.log is on the CI without the changes, in here we can see after the first this displayIfNeeded there are multiple calls to _implicitlyAllowsFullScreenPrimary with cb=0x0

[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT_ECB displayIfNeeded.enter                         window=0x14d374e00 cb=0x0 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT _currentlyAllowsFullScreenMode window=0x14d374e00 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x14d374e00 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT showsFullScreenButton window=0x14d374e00 result=1
[task 2026-05-12T13:11:31.125+00:00] 13:11:31     INFO -  FELT _zoomButtonIsFullScreenButton window=0x14d374e00 result=1
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT _currentlyAllowsFullScreenMode window=0x14d374e00 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x14d374e00 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT_ECB displayIfNeeded.enter                         window=0x14d374e00 cb=0x0 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT **_implicitlyAllowsFullScreenPrimary** window=0x14d374e00 class=ToolbarWindow cb=0x0 result=1 isSheet=0 parent=0x0 level=0 wasModal=0 isTitled=1 isResizable=1 screen=0x12974bee0 frame=1x29 aux105=0 aux102=0x0
[task 2026-05-12T13:11:31.126+00:00] 13:11:31     INFO -  FELT _currentlyAllowsFullScreenMode window=0x14d374e00 result=1 attachedSheet=0x0 sheets.count=0

In teststart_withchanges_ci_macos153.log after ``CreateNativeWindow.endno calls at all withcb=0x880```

[task 2026-05-12T13:11:43.443+00:00] 13:11:43     INFO -  FELT_ECB CreateNativeWindow.end                        window=0x13a282300 cb=0x880 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-12T13:11:43.443+00:00] 13:11:43     INFO -  FELT _currentlyAllowsFullScreenMode window=0x13a282300 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x13a282300 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT_ECB displayIfNeeded.enter                         window=0x13a282300 cb=0x880 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _currentlyAllowsFullScreenMode window=0x13a282300 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x13a282300 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT showsFullScreenButton window=0x13a282300 result=1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _zoomButtonIsFullScreenButton window=0x13a282300 result=1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _currentlyAllowsFullScreenMode window=0x13a282300 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x13a282300 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT_ECB displayIfNeeded.enter                         window=0x13a282300 cb=0x880 ecb=0x8a4 HAS_PRIMARY transparent=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _currentlyAllowsFullScreenMode window=0x13a282300 result=1 attachedSheet=0x0 sheets.count=0
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _cacheAndSetPropertiesForCollectionBehavior: window=0x13a282300 cb=0x8a4 windowNum=-1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT showsFullScreenButton window=0x13a282300 result=1
[task 2026-05-12T13:11:43.444+00:00] 13:11:43     INFO -  FELT _zoomButtonIsFullScreenButton window=0x13a282300 result=1
Depends on: 2038980
Crash Signature: [@ NSViewUpdateVibrancyForSubtree] → @ -[NSApplication _crashOnException:]
Crash Signature: @ -[NSApplication _crashOnException:] → @ [NSApplication _crashOnException:]
Crash Signature: @ [NSApplication _crashOnException:] → [@ -[NSApplication _crashOnException:]]
Crash Signature: [@ -[NSApplication _crashOnException:]] → [@ -[NSApplication _crashOnException:] | NSViewUpdateVibrancyForSubtree ]
Status: REOPENED → RESOLVED
Closed: 1 month ago13 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: