Question

I have an app with callbacks for recording and playing audio. From the recording callback, I call a function to update the GUI:

[mainViewController performSelectorOnMainThread:@selector(updateGuiAfterOnset) withObject:nil waitUntilDone:NO];

It works ok, but after I send the app to background (using the device's home button) and open it up again, the app crashes after the 2nd call to updateGuiAfterOnset, and specifically, it crashes after calling to:

[myUIImageView setImage:myUIImage];

The only things I do in applicationWillResignActive and applicationDidBecomeActive, are stopping and starting the audioUnit:

AudioOutputUnitStop(audioUnit);

and

AudioOutputUnitStart(audioUnit);

My intuition is that some variable is messed up during the going-to-background/foreground process, but that's only a guess.

Any ideas? Are there any recommended thing I need to do when going to background in a multi-threaded app?

EDIT The app crashes also if the gui-updating-method is called from the main thread (by tapping a button).

The relevant part from the crash report:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x000027d8 objc_msgSend + 16
1   UIKit                               0x00009738 -[UIImageView setImage:] + 140
2   TimeKeeper                          0x00002b7a -[MainViewController updateGuiAfterOnset] (MainViewController.m:89)
3   CoreFoundation                      0x0003e2e4 -[NSObject(NSObject) performSelector:withObject:] + 16
Was it helpful?

Solution

Looks like myUIImage is not valid. Was it autoreleased or manually realeased by mistake.

OTHER TIPS

It would suggest myUIImageView is not retained.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top