You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift version 4.1-dev (LLVM 260a9efcdb, Clang b58a3e2689, Swift 5037e07171)
macOS 10.12.6 (16G29)
Additional Detail from JIRA
Votes
4
Component/s
Foundation
Labels
Bug
Assignee
geza.miklo (JIRA)
Priority
Medium
md5: 42af7aecb7147cf61ba7e61216a1c14a
Issue Description:
According to the WWDC video for the new Foundation block-based KeyPath observation mechanism, when the NSKeyValueObservation returned by observe() is nilled out, the observation should be torn down:
foochanged: Bardeinitwascalled2017-08-2312:22:01.950Untitled[85112:12623133] *** Terminatingappduetouncaughtexception'NSInternalInconsistencyException', reason: 'An instance 0x7fff2cc09840 of class Untitled.C was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x7fff2cc0d8f0> (
<NSKeyValueObservance0x7fff2cc0f7b0: Observer: 0x7fff2cc0bdc0, Keypath: foo, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x7fff2cc0d820>
)'
*** Firstthrowcallstack:
(
0CoreFoundation0x00007fff9ffde2cb__exceptionPreprocess + 1711libobjc.A.dylib0x00007fffb4e1d48dobjc_exception_throw + 482CoreFoundation0x00007fffa005cc3d +[NSExceptionraise:format:] + 2053Foundation0x00007fffa19bc384NSKVODeallocate + 2934Untitled0x000000010225bc35main + 1335libdyld.dylib0x00007fffb5703235start + 1
)
libc++abi.dylib: terminatingwithuncaughtexceptionoftypeNSExceptionAborttrap: 6
As you can see, the observation is still active, even after the observation token has both had .invalidate() called on it and been nilled out. This severely hampers the usefulness of the new observation functionality, since there doesn't appear to be any obvious way to use it without eventually crashing.
The text was updated successfully, but these errors were encountered:
This is affecting me too, now. I'm trying to observe an NSRunningApplication's termination, but when it terminates this crash occurs because I don't get a chance to disconnect the observer; the observation block is never called
Still having this issue with Swift 5.1 vs iOS 10.3. The observers are stuck, cannot invalidate not remove them. There are still a large number of our users, using iOS 10
Environment
Swift version 4.1-dev (LLVM 260a9efcdb, Clang b58a3e2689, Swift 5037e07171)
macOS 10.12.6 (16G29)
Additional Detail from JIRA
md5: 42af7aecb7147cf61ba7e61216a1c14a
Issue Description:
According to the WWDC video for the new Foundation block-based KeyPath observation mechanism, when the NSKeyValueObservation returned by observe() is nilled out, the observation should be torn down:
https://developer.apple.com/videos/play/wwdc2017/212/
However, this does not seem to be the case in practice, as you can see by running this program:
When compiled and run, this program outputs:
As you can see, the observation is still active, even after the observation token has both had .invalidate() called on it and been nilled out. This severely hampers the usefulness of the new observation functionality, since there doesn't appear to be any obvious way to use it without eventually crashing.
The text was updated successfully, but these errors were encountered: