ap4y / OrigamiEngine

Lightweight audio engine for iOS and OSX with flac, cue, mp3, m4a, m3u support.
http://ap4y.github.com/OrigamiEngine/
MIT License
545 stars 118 forks source link

Dealloc crash while using KVO #58

Open obrhoff opened 9 years ago

obrhoff commented 9 years ago

Sometimes Origiami Crashes because an KVO hasn't been unsubscribed while dealloc.

'NSInternalInconsistencyException', reason: 'An instance 0x7b875c40 of class ORGMInputUnit was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x78f1c020> (
<NSKeyValueObservance 0x78f1bfe0: Observer: 0x78f67c90, Key path: endOfInput, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x78ff3de0>
)'
*** First throw call stack:
(
    0   CoreFoundation                      0x01dd1466 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x04f5ca97 objc_exception_throw + 44
    2   CoreFoundation                      0x01dd138d +[NSException raise:format:] + 141
    3   Foundation                          0x04b88dd4 NSKVODeallocate + 379
    4   libobjc.A.dylib                     0x04f71772 _ZN11objc_object17sidetable_releaseEb + 248
    5   libobjc.A.dylib                     0x04f70e9b objc_release + 43
    6   libobjc.A.dylib                     0x04f59bd8 objc_setProperty_nonatomic + 48
    7   vinylify                            0x00293552 -[ORGMConverter setInputUnit:] + 66
    8   vinylify                            0x00292657 -[ORGMConverter dealloc] + 151
    9   libobjc.A.dylib                     0x04f71772 _ZN11objc_object17sidetable_releaseEb + 248
    10  libobjc.A.dylib                     0x04f70e9b objc_release + 43
    11  libobjc.A.dylib                     0x04f59bd8 objc_setProperty_nonatomic + 48
    12  vinylify                            0x00297092 -[ORGMOutputUnit setConverter:] + 66
    13  vinylify                            0x0029649e -[ORGMOutputUnit stop] + 78
    14  vinylify                            0x002961d7 -[ORGMOutputUnit dealloc] + 55
    15  libobjc.A.dylib                     0x04f71772 _ZN11objc_object17sidetable_releaseEb + 248
    16  libobjc.A.dylib                     0x04f70e9b objc_release + 43
    17  libobjc.A.dylib                     0x04f59bd8 objc_setProperty_nonatomic + 48
    18  vinylify                            0x00295232 -[ORGMEngine setOutput:] + 66
    19  vinylify                            0x00293de6 __42-[ORGMEngine playUrl:withOutputUnitClass:]_block_invoke + 950
    20  libdispatch.dylib                   0x05a825ea _dispatch_call_block_and_release + 15
    21  libdispatch.dylib                   0x05aa4bef _dispatch_client_callout + 14
    22  libdispatch.dylib                   0x05a88d61 _dispatch_queue_drain + 544
    23  libdispatch.dylib                   0x05a889cb _dispatch_queue_invoke + 212
    24  libdispatch.dylib                   0x05a8c012 _dispatch_root_queue_drain + 615
    25  libdispatch.dylib                   0x05a8db70 _dispatch_worker_thread3 + 115
    26  libsystem_pthread.dylib             0x05e001da _pthread_wqthread + 724
    27  libsystem_pthread.dylib             0x05dfde2e start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException```
rperney commented 9 years ago

+1 same here

daria-kopaliani commented 9 years ago

+1

ap4y commented 9 years ago

I will try to look into it over the weekend.

diogobalseiro commented 9 years ago

+1

diogobalseiro commented 9 years ago

This commit may have fixed this: b504080a03a33c42a25917a8babb986ccce4c52c

freemanlam commented 7 years ago

Tried add [_input removeObserver:self forKeyPath:@"endOfInput"]; after [self removeObserver:self forKeyPath:@"currentState"]; in ORGMEngine.m and works

TiSsaa commented 7 years ago

+1

TiSsaa commented 7 years ago

Resolved by adding: [self.output release]; In class ORGMEngine at function - (void)playUrl:(NSURL *)url withOutputUnitClass:(Class)outputUnitClass:

ORGMOutputUnit *output = [[outputUnitClass alloc] initWithConverter:_converter]; output.outputFormat = _outputFormat; [self.output release]; self.output = output; [output release];