Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

watchOS 6 WKInterfaceImage crash on deallocation

since the first beta of the watchOS 6 SDK my app started crashing if compiled with the watchOS 6.0 SDK. The issues does not occur with watchOS 6.1 and happens more often in the simulator. Now I have been able to identify the issue:

I have an WKInterfaceImage that is displaying a spinner animated by using a series of images. If I have a new WKInterfaceController pushed that shows such a spinner it will crash when the view gets dismissed. Internally that is using SPInterfaceImageView which seems to get released twice.

Here's the Xcode Log message:

-[SPInterfaceImageView release]: message sent to deallocated instance 0x3971ed60

Has anyone experienced the same issue? I guess this is a bug in the watchOS SDK.

I cannot give any source code as this is happening just by using Storyboards. My development language is Swift.

Kind regards
Alexander Heinich

like image 247
Sn0wfreeze Avatar asked Oct 15 '19 08:10

Sn0wfreeze


2 Answers

Okay after I asked the question I finally discovered what causes this issues!

If your watchOS App uses animated images like the spinner that I described in the question it is necessary with the watchOS 6 SDK to call image.stopAnimating() before the WKInterfaceController gets dismissed.

This can be done in the didDeactivate() method or when the image view gets dismissed. It is not enough to just show hide the image view! It also helps when the image view has a fixed size.

I hope this helps anyone who gets some of those error messages: EXC_BAD_INSTRUCTION with _UIImageContentContextualEffect .cxx_destruct in the stack trace

or the above mentioned -[SPInterfaceImageView release]: message sent to deallocated instance

like image 196
Sn0wfreeze Avatar answered Oct 26 '22 06:10

Sn0wfreeze


I experienced the same issue and managed to get around it by passing a non-zero value for the repeatCount parameter of startAnimatingWithImages(in:duration:repeatCount:)

So I ended up with something like this:

setImageNamed("spinner")
startAnimatingWithImages(in: NSRange(location: 0, length: 6), duration: 0.75, repeatCount: 9999)

Pretty weird, but it stopped the crashes.

like image 2
Rowan Avatar answered Oct 26 '22 06:10

Rowan