Hi,
my JUCE iOS app crashes reliably when I start it on an upside down iPhone or emulator (home button at top). It crashes in file juce_ios_UIViewComponentPeer.mm :
static void sendScreenBoundsUpdate (JuceUIViewController* c)
{
JuceUIView* juceView = (JuceUIView*) [c view]; // <--- crash
if (juceView != nil && juceView->owner != nullptr)
juceView->owner->updateTransformAndScreenBounds();
}
Debugging the issue, it crashes because c is a stale pointer to an already deleted object.
I found that this method is called asynchronously from here:
- (void) viewWillTransitionToSize: (CGSize) size withTransitionCoordinator: (id<UIViewControllerTransitionCoordinator>) coordinator
{
[super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];
sendScreenBoundsUpdate (self);
// On some devices the screen-size isn't yet updated at this point, so also trigger another
// async update to double-check..
MessageManager::callAsync ([=] { sendScreenBoundsUpdate (self); }); // <--- async call
}
Apparently, self gets deleted before the sendScreenBoundsUpdate() is called asynchronously.
The following replacement of that last line fixes it for me. It makes sure that self is not deleted until used by sendScreenBoundsUpdate().
Suggested fix:
[self retain];
MessageManager::callAsync ([=] {
sendScreenBoundsUpdate (self);
[self release];
});
Thanks for considering.
Florian
