Bug 2031249 Comment 22 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

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
```
[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] 
[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, so there is an internal change, because of this change in the middle of enumeration the function `_cacheAndSetPropertiesForCollectionBehavior` is triggering some side effects that are leading to the crash.

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 not called(as the ECB did not change) and no mutations happen
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.
```
[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] 
[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, so there is an internal change, because of this change in the middle of enumeration the function `_cacheAndSetPropertiesForCollectionBehavior` is triggering some side effects that are leading to the crash.

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 not called(as the ECB did not change) and no mutations happen
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.
```
[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] 
[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, so there is an internal change, because of this change in the middle of enumeration the function `_cacheAndSetPropertiesForCollectionBehavior` is triggering some side effects that are leading to the crash.

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 not called(as the ECB did not change) and no mutations happen
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.
```
[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] 
[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 not called(as the ECB did not change) and no mutations happen
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.
```
[NSWindow _cacheAndSetPropertiesForCollectionBehavior:] 
[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 not called(as the ECB did not change) and no mutations happen
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 not called(as the ECB did not change) and no mutations happen
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.

Back to Bug 2031249 Comment 22