NSInternalInconsistencyException assertion from [NSRemoteView containingWindowWillOrderOnScreen:] on macOS 27 (26A5378j)

Is anyone else getting these assertion crashes on developer beta 3 of Golden Gate? I've gotten more than a dozen crash logs from users running macOS 27 (26A5378j) that all look like this:

assertion failed: '<NSRemoteView: 0x79cb366700 com.apple.SafariPlatformSupport.Helper SPCompletionListServiceViewController> notified of <NSStatusBarWindow: 0x79cbef7480> but expected (null)' in -[NSRemoteView containingWindowWillOrderOnScreen:] on line 4221 of file /AppleInternal/Library/BuildRoots/4~CSuOugB1YCxzYMPRWEumvvfCTNtf98eItTmsbJU/Library/Caches/com.apple.xbs/TemporaryDirectory.N8fh9t/Sources/ViewBridge/NSRemoteView.m

but with various windows from my app after "notified of".

They're getting thrown when one of my windows is made frontmost, either using NSWindow.orderFrontRegardless or NSWindow.makeKeyAndOrderFront, or (in the case above) when my status item is shown. It's intermittent - I've been unable to reproduce it so far - but definitely happening repeatedly based on my Sentry crash logging.

Is this a bug in Golden Gate b3, or am I doing something to provoke this? I've submitted it via Feedback Assistant (FB23642313).

Thanks

  • Jon

P.S. Full stack trace attached for the exception thrown when the assertion fails for NSStatusBarWindow

Answered by DTS Engineer in 897814022

Thank you for reporting.

I am relating your reports and making sure they are routed to the correct engineering team. Updates will be provided to you through Feedback Assistant. There, you can track if the report is still being investigated, has a potential identified fix, or has been resolved in another way.

For more details on Feedback Status, please see “Understanding the Status of Your Feedback” linked here: https://developer.apple.com/bug-reporting/status

When we receive multiple reports, it helps us understand the impact of an issue which can drive priority, so thank you.

 Travis

We're seeing this error as well. In our case, it occurs when a child NSWindow contains an editable text field: closing that window and opening a new one triggers the crash. We've found that removing the editable text field prevents the crash, but this is clearly a bug in Golden Gate Beta 3...

I experience the same crash in my app on macOS 27 beta. It happens when I call NSAlert.beginSheetModalForWindow

My stack trace:

Application Specific Backtrace 0:
0   CoreFoundation                      0x000000018bb76448 __exceptionPreprocess + 176
1   libobjc.A.dylib                     0x000000018b5d45e4 objc_exception_throw + 88
2   CoreFoundation                      0x000000018bb9af50 _CFBundleGetValueForInfoKey + 0
3   ViewBridge                          0x00000001966063f0 -[NSRemoteView containingWindowWillOrderOnScreen:] + 216
4   CoreFoundation                      0x000000018bafafc4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
5   CoreFoundation                      0x000000018bb89e88 ___CFXRegistrationPost_block_invoke + 92
6   CoreFoundation                      0x000000018bb89dcc _CFXRegistrationPost + 440
7   CoreFoundation                      0x000000018bac7300 _CFXNotificationPost + 688
8   Foundation                          0x000000018d1ad384 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
9   AppKit                              0x000000019005c970 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 28
10  AppKit                              0x0000000190994ad0 -[NSWindow _reallyDoOrderWindowAboveOrBelow:] + 1104
11  AppKit                              0x0000000190995698 -[NSWindow _reallyDoOrderWindow:] + 64
12  AppKit                              0x000000019099591c -[NSWindow _doOrderWindow:] + 300
13  AppKit                              0x000000019018de4c -[NSApplication _orderFrontModalWindow:relativeToWindow:] + 268
14  AppKit                              0x00000001901cc984 -[NSWindow _beginWindowBlockingModalSessionForSheet:service:completionHandler:isCritical:] + 1016
15  AppKit                              0x000000019020db2c __54-[NSAlert beginSheetModalForWindow:completionHandler:]_block_invoke + 280
16  AppKit                              0x000000019020ab90 -[NSAlert beginSheetModalForWindow:completionHandler:] + 116

I've also submitted it: FB23794308

My feedback has been updated with "Potential fix identified - For a future OS update", so I'm hopeful we'll see a fix in the next beta release.

Accepted Answer

Thank you for reporting.

I am relating your reports and making sure they are routed to the correct engineering team. Updates will be provided to you through Feedback Assistant. There, you can track if the report is still being investigated, has a potential identified fix, or has been resolved in another way.

For more details on Feedback Status, please see “Understanding the Status of Your Feedback” linked here: https://developer.apple.com/bug-reporting/status

When we receive multiple reports, it helps us understand the impact of an issue which can drive priority, so thank you.

 Travis

Hi,

Any progress on that? I receive a lot of crash reports caused by this bug. I also searched the internet and many users across many different apps experience the same issue. It seems to be a critical bug.

It's still reproducible using beta 4.

I ran into the same issue on all three beta builds:

  • 26A5388g
  • 26A5378n
  • 26A5378j

I added a guard as a workaround. My app has been live for about two weeks, and since releasing the new version, the crashes have stopped.

Hopefully Apple can fix this issue soon.

Guard code:

@implementation TBRemoteViewCrashGuard

+ (void)install {
    if (![self shouldInstall]) {
        return;
    }

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        [self swizzleContainingWindowWillOrderOnScreen];
    });
}

#pragma mark - Private

/// 仅在 macOS 27 上生效(Beta 系统存在此 Bug)
+ (BOOL)shouldInstall {
    NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
    // macOS 27.x — 待 Apple 正式版确认修复后可收窄条件或移除
    return version.majorVersion == 27;
}

+ (void)swizzleContainingWindowWillOrderOnScreen {
    Class cls = NSClassFromString(@"NSRemoteView");
    if (!cls) {
        return;
    }

    SEL originalSel = NSSelectorFromString(@"containingWindowWillOrderOnScreen:");
    Method originalMethod = class_getInstanceMethod(cls, originalSel);
    if (!originalMethod) {
        return;
    }

    // 用 block 包裹原实现,加 @try/@catch 防止断言崩溃
    IMP originalIMP = method_getImplementation(originalMethod);

    IMP guardedIMP = imp_implementationWithBlock(^(id self, NSWindow *window) {
        @try {
            ((void(*)(id, SEL, NSWindow *))originalIMP)(self, originalSel, window);
        } @catch (NSException *exception) {
            // 仅吞掉 NSRemoteView 的断言异常,其它异常继续抛出
            if ([exception.name isEqualToString:NSInternalInconsistencyException]
                && [exception.reason containsString:@"NSRemoteView"]) {
                TBLogInfo(@"[RemoteViewCrashGuard] Suppressed NSRemoteView assertion: %@", exception.reason);
            } else {
                @throw;
            }
        }
    });

    method_setImplementation(originalMethod, guardedIMP);
    TBLogInfo(@"[RemoteViewCrashGuard] Installed for macOS %ld.x", (long)[[NSProcessInfo processInfo] operatingSystemVersion].majorVersion);
}

@end

The crash stack

Date/Time:           2026-07-30 21:42:43.527 +0800
OS Version:          macOS 27.0 (26A5388g)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000000000000
Triggered by Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'assertion failed: '<NSRemoteView: 0x7a4d228900 com.apple.SafariPlatformSupport.Helper SPCompletionListServiceViewController> notified of <NSStatusBarWindow: 0x7a4d3e3200> but expected (null)' in -[NSRemoteView containingWindowWillOrderOnScreen:] on line 4221 of file /AppleInternal/Library/BuildRoots/4~CTiUugCoYHT2c7uJUlZ579eHNtPUHFSW5CSk0cY/Library/Caches/com.apple.xbs/TemporaryDirectory.PDwelI/Sources/ViewBridge/NSRemoteView.m'

Thread 0 Crashed:
0   CoreFoundation                	0x00000001892ca43c __exceptionPreprocess + 164
1   libobjc.A.dylib               	0x0000000188d285e4 objc_exception_throw + 88
2   CoreFoundation                	0x00000001892eef4c -[NSException raise] + 16
3   ViewBridge                    	0x0000000193ed13f0 -[NSRemoteView containingWindowWillOrderOnScreen:] + 216
4   CoreFoundation                	0x000000018924efc4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
5   CoreFoundation                	0x00000001892dde84 ___CFXRegistrationPost_block_invoke + 92
6   CoreFoundation                	0x00000001892dddc8 _CFXRegistrationPost + 440
7   CoreFoundation                	0x000000018921b304 _CFXNotificationPost + 688
8   Foundation                    	0x000000018a900384 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
9   AppKit                        	0x000000018d8f3800 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 28
10  AppKit                        	0x000000018e14e12c -[NSWindow _reallyDoOrderWindowAboveOrBelow:] + 1104
11  AppKit                        	0x000000018e14ecf4 -[NSWindow _reallyDoOrderWindow:] + 64
12  AppKit                        	0x000000018e14ef78 -[NSWindow _doOrderWindow:] + 300
13  AppKit                        	0x000000018df7759c orderWindowFrontInAppKitOnly + 52
14  AppKit                        	0x000000018de3aea0 -[NSSceneStatusItem _wakeStatusItem] + 188
15  AppKit                        	0x000000018de3cc28 -[NSSceneStatusItem _connectVariantViewScene:] + 440
16  AppKit                        	0x000000018df6bb10 -[NSStatusBar(NSInternal) _connectVariantViewScene:] + 160
17  AppKit                        	0x000000018e57e55c -[NSStatusItemVariantSceneDelegate scene:willConnectToSession:options:] + 60
......

I can confirm that the workaround prepared by @JyHu works perfect. Thank you! Your fix is going to make life easier for many users! :)

Here is Swift version:

enum RemoteViewCrashGuard {
    private static var isInstalled = false

    static func install() {
        guard shouldInstall, !isInstalled else { return }

        isInstalled = true
        swizzleContainingWindowWillOrderOnScreen()
    }

    // MARK: - Private

    /// Only macOS 27 is affected by the beta bug.
    private static var shouldInstall: Bool {
        ProcessInfo.processInfo.operatingSystemVersion.majorVersion == 27
    }

    private static func swizzleContainingWindowWillOrderOnScreen() {
        guard let remoteViewClass = NSClassFromString("NSRemoteView") else { return }

        let selector = NSSelectorFromString("containingWindowWillOrderOnScreen:")
        guard let method = class_getInstanceMethod(remoteViewClass, selector) else { return }

        // Wrap the original implementation so the assertion is caught instead of
        // crashing. Only NSRemoteView's inconsistency is swallowed; anything
        // else is re-raised so we don't mask unrelated bugs.
        typealias OriginalFunction = @convention(c) (AnyObject, Selector, NSWindow?) -> ()
        let originalIMP = method_getImplementation(method)
        let callOriginal = unsafeBitCast(originalIMP, to: OriginalFunction.self)

        let guardedBlock: @convention(block) (AnyObject, NSWindow?) -> () = { receiver, window in
            let exception = ObjCExceptionCatcher.catchException {
                callOriginal(receiver, selector, window)
            }
            guard let exception else { return }

            if exception.name == .internalInconsistencyException,
               exception.reason?.contains("NSRemoteView") == true {
                print("[RemoteViewCrashGuard] Suppressed NSRemoteView assertion: \(exception.reason ?? "")")
            } else {
                exception.raise()
            }
        }

        method_setImplementation(method, imp_implementationWithBlock(guardedBlock))

        print(
            "[RemoteViewCrashGuard] Installed for macOS \(ProcessInfo.processInfo.operatingSystemVersion.majorVersion).x"
        )
    }
}

ObjCExceptionCatcher.h:

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// Bridges Objective-C exception handling to Swift, which cannot catch
/// `NSException`. Runs `tryBlock` inside an `@try/@catch` and returns any
/// raised exception instead of letting it unwind and crash the app.
@interface ObjCExceptionCatcher : NSObject

/// Runs `tryBlock`, returning the `NSException` it raised, or `nil` if it
/// completed normally.
+ (nullable NSException *)catchException:(NS_NOESCAPE void (^)(void))tryBlock;

@end

NS_ASSUME_NONNULL_END

ObjCExceptionCatcher.m

#import "ObjCExceptionCatcher.h"

@implementation ObjCExceptionCatcher

+ (NSException *)catchException:(NS_NOESCAPE void (^)(void))tryBlock {
    @try {
        tryBlock();
        return nil;
    } @catch (NSException *exception) {
        return exception;
    }
}

@end
NSInternalInconsistencyException assertion from [NSRemoteView containingWindowWillOrderOnScreen:] on macOS 27 (26A5378j)
 
 
Q