FileChooser iOS crashes with double click

There appears to be a bug with the FileChooser on iOS when you “double click” on a file to open it.

This can be reproduced with the DemoRunner using the AudioPlaybackDemo.h example. Laugh the AudioPlaybackDemo.h and select “Choose Audio File…”. When you are presented with the iOS FileChooser, “double click” or “double tap” an audio file to open.

The application will crash.

It seems like there is some refcounting issues with AsyncUpdater and cancelPendingUpdate with the FileChooser on iOS.

Any ideas on how to fix this?

JUCE v7.0.7

2023-12-01 15:07:16.437576-0700 DemoRunner[54252:22245477] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named “(no name)”)

2023-12-01 15:07:17.167486-0700 DemoRunner[54252:22245477] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000029a45c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46

2023-12-01 15:07:17.462779-0700 DemoRunner[54252:22245477] [general] Error loading /Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter (71): dlopen(/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter, 0x0106): tried: ‘/Users/bbrown/code/juce/juce7/examples/DemoRunner/Builds/iOS/build/Debug/JackRouter’ (errno=2), ‘/Applications/Xcode-14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/JackRouter’ (errno=2), ‘/Applications/Xcode-14.2.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter’ (errno=2), ‘/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter’ (mach-o file (/Library/Audio/Plug-Ins/HAL/JackRouter.plugin/Contents/MacOS/JackRouter), but incompatible platform (have ‘unknown’, need ‘iOS-sim’))

2023-12-01 15:07:17.462954-0700 DemoRunner[54252:22245477] [plugin] Cannot find function pointer New_JackRouterPlugIn for factory <CFUUID 0x6000029d9dc0> 7CB18864-927D-48B5-904C-CCFBCFBC7ADD in CFBundle/CFPlugIn 0x7f863c004280 </Library/Audio/Plug-Ins/HAL/JackRouter.plugin> (bundle, not loaded)

2023-12-01 15:07:18.650223-0700 DemoRunner[54252:22245630] Metal GPU Frame Capture Enabled

2023-12-01 15:07:18.650551-0700 DemoRunner[54252:22245630] Metal API Validation Enabled

2023-12-01 15:07:18.710847-0700 DemoRunner[54252:22245630] fopen failed for data file: errno = 2 (No such file or directory)

2023-12-01 15:07:18.711132-0700 DemoRunner[54252:22245630] Errors found! Invalidating cache…

2023-12-01 15:07:18.789354-0700 DemoRunner[54252:22245630] fopen failed for data file: errno = 2 (No such file or directory)

2023-12-01 15:07:18.789607-0700 DemoRunner[54252:22245630] Errors found! Invalidating cache…

2023-12-01 15:07:42.955296-0700 DemoRunner[54252:22245477] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named “(no name)”)

2023-12-01 15:07:55.875903-0700 DemoRunner[54252:22245477] [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 “(null)” UserInfo={Terminated=disconnect method}

2023-12-01 15:08:05.284411-0700 DemoRunner[54252:22245477] [SystemGestureGate] <0x7f8639d0af10> Gesture: System gesture gate timed out.

2023-12-01 15:08:11.619511-0700 DemoRunner[54252:22245477] [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 “(null)” UserInfo={Terminated=disconnect method}

JUCE Assertion failure in juce_ReferenceCountedObject.h:394

(lldb)

On which version of iOS, and with which Xcode version, are you seeing this issue? With iOS 17 I’m not able to reproduce the problem. I have a theory about what might be going wrong, but ideally I’d test out the change before pushing any fixes.

Reuk,

I’m using Xcode-14.3.1 and Xcode-14.2.app (running on macOS Monterey 12.6.6).

This happens on an iPad Pro 5th get running iOS 16.7.

Thanks,
Bob

Unfortunately I can’t repro on the iOS 16.4 simulator, and I don’t have a physical device running iOS 16.7.

Please could you try applying the attached patch, and check whether the problem persists? Thanks!

filechooser-ios.patch (5.2 KB)

The above patch is now on develop. Please try it out and check whether the problem persists. Thanks!

Hi,

I had the same issue. But the develop change seems not to change my issue, still if I double tab the file in the IOS-FileChooser, there is a bad access, but this time the bad acces happens here:
line 147:
passResultsToInitiator (std::move (result));
line 245:
owner.finished (std::move (urls));
line 262:
const auto callback = std::exchange (asyncCallback, nullptr);

I am using a real Ipad latest OS.
Thanks for looking at this issue, would say it should have high prio, but who am I ;).

Best equinox…