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

Freezing on macOS M1 #957

Closed
1 of 4 tasks
tannermeade opened this issue Feb 4, 2022 · 20 comments
Closed
1 of 4 tasks

Freezing on macOS M1 #957

tannermeade opened this issue Feb 4, 2022 · 20 comments
Labels
desktop The issue applies to Windows, Linux or MacOS implementations. help wanted Extra attention is needed new issue An issue that hasn't yet been seen from the maintainer stale

Comments

@tannermeade
Copy link

tannermeade commented Feb 4, 2022

Describe the bug
File picker freezes often on macOS M1 devices on v 4.3.3 (and many versions before). This issue (#778) should be reopened or this new issue should be used to track it.

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
What version did it happen?
Several versions, but confirmed on macOS 11.6 (20G165)

How are you picking?

var pickedFiles = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['csv'],
      allowMultiple: true,
);

Details to reproduce the issue
On an M1 macOS, use the FilePicker in most any way, specifically you can use multiple files and only allow CSV and it freezes often.

Error Log
The app freezes. For a few seconds, the cursor stays as a click cursor until it turns to the turning beachball. Only way to stop it is to force close the app or stop the run time.

Screenshots and/or video
If applicable, add screenshots or video to help explain your problem.

Flutter Version details
Has happened on several channels for a long time and the last several versions of Flutter, but here is my current doctor:

[✓] Flutter (Channel stable, 2.10.0, on macOS 11.6 20G165 darwin-arm, locale en-US)
    • Flutter version 2.10.0 at /Users/tannermeade/Coding/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5f105a6ca7 (3 days ago), 2022-02-01 14:15:42 -0800
    • Engine revision 776efd2034
    • Dart version 2.16.0
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/tannermeade/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.5.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/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 1.8.0_242-release-1644-b3-6915495)

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

[✓] VS Code (version 1.64.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 11.6 20G165 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99

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

! Doctor found issues in 1 category.

Additional context
This issue has been reported several times in this issue: #778

@tannermeade tannermeade added the new issue An issue that hasn't yet been seen from the maintainer label Feb 4, 2022
@philenius philenius added the desktop The issue applies to Windows, Linux or MacOS implementations. label Feb 4, 2022
@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Feb 12, 2022
@henry2man
Copy link

Hi, just my 2 cents. I'm having issues like this using both Flutter Desktop for MacOS (using a MBP M1) and Flutter Web.

In my case I've detected that first open usually works but subsequent tries freezes.

As a workaround I've implemented a Drag&Drop zone. It's not perfect but it works as a replacement.

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Feb 20, 2022
@philenius philenius removed the stale label Feb 26, 2022
@philenius
Copy link
Collaborator

philenius commented Feb 26, 2022

@peacememories: my following answer applies to your issue #964 as well.

@tannermeade: thank you for reporting this issue and for using our issue template. As you already figured out, there's a similar issue #964.

You mentioned that your issue would be related to #778, but you're clearly describing an issue with the desktop implementation of file_picker on macOS. However, issue #778 was related to the iOS device simulator. So I think that these are different problems.

Since I don't own a physical Apple device, let alone a MacBook with M1 processor, I'm afraid that I can't help you with your reported issue. I just tried again with our latest version, file_picker works fine on the virtual device I am testing on. There are two ways how you could help yourself:

  1. You could debug our fairly simple implementation for macOS (see https://github.com/miguelpruivo/flutter_file_picker/blob/master/lib/src/file_picker_macos.dart). Basically, to open any kind of dialog on macOS, we simply execute a shell command. This is obviously not the professional approach (PRs are welcome). For instance, for opening the file picker, we execute:

    osascript -e 'choose file of type {"csv"} with multiple selections allowed'

    You can copy paste this command to a terminal to try it out. In summary, our equivalent Dart code looks like this:

    final executable = '/usr/bin/osascript';
    final arguments = [ '-e', 'choose file of type {"csv"} with multiple selections allowed' ];
    final processResult = await Process.run(executable, arguments);
    print(processResult.stdout?.toString().trim());

    If file_picker freezes while executing this shell command, then it must be related to Flutter or macOS itself. We already had the issue on Ubuntu, that Flutter had no permissions to execute the shell command (when installed via snap). In this case, the file picker dialog didn't open up at all. Your issue is different. Please keep me posted, if you debug it and find out anything.

  2. You could switch to a more professional C++ implementation that doesn't use shell commands. Google provides its own Flutter plugin file_selector and file_selector_macos. Google says that their plugin has not yet been endorsed because it is impossible to write UI tests for their plugin (same applies to file_picker).

And yes, I can confirm that the file picker dialog takes 1-2 seconds to open. At least in my case, this delay is due to using a virtualized macOS device and still I don't have to wait 3-4 seconds. Also, the dialog never freezes or crashes even if I repeat the same procedure up to five times:
file-picker-macos

I'm sorry that I can't help you any further.

@philenius philenius added the help wanted Extra attention is needed label Feb 26, 2022
@tannermeade
Copy link
Author

@philenius thank you for the detailed help. I haven't been able to get it to freeze with just the command. I'll have to figure out how to debug it further and your direction is helpful for that. Thank you!

@swaroopmaddu
Copy link

@tannermeade I'm also on M1 mac and I have the same issue sometimes. Do you have any idea how can I solve this issue.

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Mar 10, 2022
@philenius philenius removed the stale label Mar 10, 2022
@jhsware
Copy link

jhsware commented Mar 16, 2022

I too have run in to this issue when moving from Intel Mac to M1 Mac. It appears that this issue arises when starting the application from Flutter (VS Code). If you run the same project in Xcode there is no issue. Perhaps worth filing a bug with the Flutter team, it might not be an issue with the plugin.

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Mar 24, 2022
@github-actions
Copy link

github-actions bot commented Apr 8, 2022

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Apr 8, 2022
@mgenware
Copy link

Please stop the stale bot from closing unresolved issues. I ran into this from time to time on an M1 when doing:

FilePicker.platform.getDirectoryPath()

@miguelpruivo
Copy link
Owner

Please stop the stale bot from closing unresolved issues. I ran into this from time to time on an M1 when doing:

FilePicker.platform.getDirectoryPath()

@philenius answer was pretty straight forward. Neither I or him can't provide any help regarding this at the moment because seems like we both don't own M1 Macs and makes it harder to replicate or even diagnose what can be done in order to prevent/fix it.

Anyone with a M1 Mac experiencing this issue, is welcome to contribute and issue a PR with a fix for it.

@miguelpruivo miguelpruivo reopened this Apr 18, 2022
@github-actions github-actions bot removed the stale label Apr 19, 2022
@oddko
Copy link

oddko commented Apr 19, 2022

M1 Pro user here, had the issue as well but it does not seem to happen anymore on the current beta channel of flutter (2.13-pre as I speak).

@jhack7
Copy link

jhack7 commented Apr 22, 2022

I am having this issue as well. I am amble to consistently reproduce the issue when calling getDirectoryPath if finder is open in the path to the default path of getDirectoryPath

unfortunately up to this point I haven't been able to debug the actual issue, I am still troubleshooting but I am curious to see if others are able to reproduce in a similar way

@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Apr 30, 2022
@FlorianGrollich
Copy link

FlorianGrollich commented May 6, 2022

I was able to reproduce it by calling pickFiles in an onTap function of a GestureDetector. But it only freezes if the initial directory is Recents.

Another way to reproduce it is if you call the pickFiles with the onTap Function of the GestureDetector and spam click it, but that obviously does make more sense. ^^

@github-actions github-actions bot removed the stale label May 7, 2022
@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label May 14, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@sergioisair
Copy link

hello, any solution for freezing?

@stephane-archer
Copy link
Collaborator

#1628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop The issue applies to Windows, Linux or MacOS implementations. help wanted Extra attention is needed new issue An issue that hasn't yet been seen from the maintainer stale
Projects
None yet
Development

No branches or pull requests