开发者

app crashes after becoming active, when calling [UIImageView setImage:]

开发者 https://www.devze.com 2023-02-09 03:19 出处:网络
I have an app with callbacks for recording and playing audio. From the recording callback, I call a function to update the GUI:

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


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


It would suggest myUIImageView is not retained.

0

精彩评论

暂无评论...
验证码 换一张
取 消