Could someone explain this to me?

Hello,

When I try to run a program this pops up:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
abort() called
terminating with uncaught exception of type NSException

I'm not exactly sure what this means nor how to fix it, so if anyone could be so kind to give me any insight they know about this issue let me know.

Thank you
Apple’s UI frameworks can only be called from the main thread. If you break this rule, one of three things will happen:
  1. If you have the Main Thread Checker enabled, it will often trap that misbehaviour.

  2. Failing that, the problem maybe notified by the UI framework itself.

  3. Failing that, you will get mysterious and hard to reproduce runtime errors )-:

I believe you’re hitting case 2 here. My recommendation is that you set an exception breakpoint in Xcode. This will stop you when the exception is thrown, at which point you can look at the backtrace to see how you get there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Quinn,

We're hitting this very occasionally, and it seems that our document class is sometimes being dealloced on a background thread:
Code Block
4 Our App 0x0000000100043d4c -[ScriptDocumentBase dealloc] + 284
5 Foundation 0x00007fff3c249961 -[NSFilePresenterXPCMessenger dealloc] + 36
6 Foundation 0x00007fff3bfa7334 -[_NSXPCConnectionExportInfo dealloc] + 42
7 CoreFoundation 0x00007fff399eb6e5 __CFBasicHashRemoveValue + 141
8 CoreFoundation 0x00007fff3990e969 CFBasicHashRemoveValue + 2989
9 CoreFoundation 0x00007fff39926935 CFDictionaryRemoveValue + 179
10 Foundation 0x00007fff3c06252c -[_NSXPCConnectionExportedObjectTable releaseExportedObject:] + 297

At first I thought it might be an artefact of running in Xcode, because we weren't seeing it in bug reports. But now I've seen it from a user, too.

Any thoughts on how to handle this?
This is likely to be The Deallocation Problem™, as defined in the so-named section of Technote 2109 Simple and Reliable Threading with NSOperation. There’s two possibilities here:
  • Your own code is taking references to a main-thread-only object from threaded code. The solution to that is the one recommend in TN2109: Stop doing that.

  • Apple code is doing this. That makes things trickier. If you’re able to prove that this is happening then you should file a bug about that (although it wouldn’t surprise me if that came back as Not to be Fixed). On the workaround front, your only option is to avoid doing main-thread-only work in your -dealloc method. This may, for example, mean that you have to treat your document class as an any-thread object and move the main-thread-only work to a separate class that you talk to using the same isolation techniques you’d use if this were your own code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thanks as always, Quinn. I'd been assuming the -[_NSXPCConnectionExportedObjectTable releaseExportedObject:] implied it was the OS's doing, but perhaps that's too simplistic a reading of things.

I'd been assuming the -[_NSXPCConnectionExportedObjectTable releaseExportedObject:] implied it was the OS's doing

Yeah, I suspect that you’re right, but it’d be good to confirm that.

Come to think of it, there’s a good way to test this theory, namely to run the app under the Allocations instrument and then look through all the retains and releases for your document object. IIRC Instruments records the thread involved, and even its backtrace.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Could someone explain this to me?
 
 
Q