Hi dear JUCE team, I found an issue in my iOS AUv3 plugin, it has a load local file function, I’m using FileChooser and use launchAsync to open iOS native load file window, but if I open the load file window, then close plugin window from DAW, the plugin would crash, saying
pointer being freed was not allocated
happens when destruct FileChooser::Native
I prepared a juce project purely for this FileChooser function for you guys to reproduce this bug, please see the attached file.
Reproduce steps:
From Xcode, debug run AUv3 in this project on a real iOS device in AUM (or any DAW supports closing plugin window)
Load this AUv3, under name “iOS AUv3 FileChooser crashing bug demo”
Open plugin window
Click any part in this plugin (button covers the whole editor)
Leave the iOS file chooser open, then close the plugin window in DAW
Crash
Btw I’m using the latest develop juce version 7.0.2
12be2e88387ecabe3b63919b6630aec6b2f8381a
“The reason is not that you didn’t allocate it, but that it is owned twice…
Smart pointers (like unique_ptr or shared_ptr) own the pointee. If two such pointers (including ObjC’s own memory management) try to delete the pointee it is called a “double delete”. The system tries to delete memory that was already free, I think it is a genuine bug in JUCE”
Hope this bug can get confirmed and fixed, my plugin is getting too many 1 star review because of this
Is this not somehow related to the fact that AUv3 plugins can no longer have child-windows (such as popup menus) because the association of the sub-window context with the main process is no longer being made (due to AUv3 sandboxing)?
I’ve seen this free error previously on our plugins, and addressed it by removing popupmenus in our GUI design, replacing them with Combo/RadioButtons instead.
But the feature I’m aiming for is let user to select his local file and import it, it better be a normal file loader for this.
And the user case which causes this bug is definitely avoid-able, I’ve checked other AUv3 plugins like Koala Sampler and FRMS, their file/preset import function does the same thing, but won’t cause crash when you close the plugin window with load window on.
They might not use JUCE, but they must used some iOS related function which JUCE can also get benefits from.
Hmmm not sure what’s going on there. It applies cleanly when I apply it to my copy of JUCE (and I’m also on 97a421f). Did you navigate to the correct JUCE folder?
In any case, here is a copy of the patched juce_ios_FileChooser.mm file. You can also just replace your copy with the file below:
Hi, just pasted the .mm codes, yes it won’t crash anymore! You guys are amazing!
I do have this printed out when closing the file chooser window with Cancel button:
[DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 “(null)” UserInfo={Terminated=disconnect method}
It won’t cause crash, but not sure if it is serious or not.
The error is a harmless warning from iOS (not JUCE) that the parent view of the file chooser was removed. Nothing we can do about this as the host hides the AUv3’s editor before we can even react.
Anyways. The fix is currently in code review and I will update this thread once it’s in the public JUCE repo.
This is now fixed with commit b01d8c3 on the develop branch.
Please don’t use the patch I sent you above: a few major issues were found during code review (thanks @reuk) which could cause other crashes or app lock-ups.