5

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

Sn0wfreeze
  • 1,959
  • 3
  • 18
  • 32

2 Answers2

20

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

Sn0wfreeze
  • 1,959
  • 3
  • 18
  • 32
  • 1
    Not sure for how long would I be stuck, if I haven't found this answer. Thanks a lot! – Konstantin Loginov Nov 26 '19 at 13:24
  • A million thanks - was going crazy trying to figure out what was happening – Chazman Feb 12 '20 at 18:32
  • 1
    Just for the record, my case was slightly different and want to document here. We had a scene that contained an WKInterfaceImage with animate set to Yes in IB. However, we did not have an IBOutlet and so no corresponding stopAnimating(). This was causing an intermitted crash in Xcode. Did not see the same behavior on the physical device. Adding the outlet and calling stopAnimating seemed to stop the crash. Seems like either a simulator or WatchOS issue but the workaround remediates – Chazman Feb 12 '20 at 19:40
2

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.

Rowan
  • 21
  • 1