Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in FileUtils:resolveType when UTTypeCreatePreferredIdentifierForTag returns NULL #1040

Closed
blaugold opened this issue May 30, 2022 · 6 comments · Fixed by #1041
Closed
Assignees

Comments

@blaugold
Copy link
Contributor

blaugold commented May 30, 2022

CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[format pathExtension], NULL);
NSString * UTIString = (__bridge NSString *)(UTI);
CFRelease(UTI);

FileUtils:resolveType does not expect UTTypeCreatePreferredIdentifierForTag to return NULL but that is what is returned when a file extension is not a known tag class.

Using json, for example, in allowedExtensions and type: FileType.custom causes a crash on iOS Simulator.

file_picker: ^4.6.0

[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale en-DE)
    • Flutter version 3.0.1 at /Users/gabriel/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (11 days ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/gabriel/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • ANDROID_HOME = /Users/gabriel/Library/Android/sdk
    • Java binary at: /Users/gabriel/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8193401/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Users/gabriel/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8193401/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] IntelliJ IDEA Community Edition (version 2021.3.3)
    • IntelliJ at /Users/gabriel/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/213.7172.25/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • iPad Pro (12.9-inch) (5th generation) (mobile) • 699338E8-F28E-412A-A6D3-6A77625B10AB • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)                                • macos                                • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)                                   • chrome                               • web-javascript • Google Chrome 102.0.5005.61

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
@miguelpruivo
Copy link
Owner

Hum, interesting. Does this happen on a real device?

@miguelpruivo miguelpruivo self-assigned this May 30, 2022
@blaugold
Copy link
Contributor Author

blaugold commented May 30, 2022

Just tried it on an iPhone and the crash does not happen there.

I worded the issue a bit incorrect. UTTypeCreatePreferredIdentifierForTag returns NULL when the tag class is not known and has nothing to do with the extension that is passed in.
Is it possible that kUTTagClassFilenameExtension is not supported on iOS simulator?

@blaugold
Copy link
Contributor Author

After googling a bit, I found basically the same issue in another project, and it seems to be Apple Silicon related.

@miguelpruivo
Copy link
Owner

I had that idea as well — that it was related with M1 issues on simulators. Unless it happens directly on real devices, this is low priority (if there is something that can actually be done or it should be fixed in a near future).

@blaugold
Copy link
Contributor Author

I think a fix is pretty simple. Just handle the case where nil is returned as the file type not being supported. I can submit a PR if you think that sounds fine.

@miguelpruivo
Copy link
Owner

miguelpruivo commented May 31, 2022

I think a fix is pretty simple. Just handle the case where nil is returned as the file type not being supported. I can submit a PR if you think that sounds fine.

Ok feel free to do it! Don't forget to also increase the patch version as well update the CHANGELOG.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants