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

In the release version, it crashes #629

Closed
sh4msi opened this issue Apr 22, 2022 · 7 comments
Closed

In the release version, it crashes #629

sh4msi opened this issue Apr 22, 2022 · 7 comments

Comments

@sh4msi
Copy link

sh4msi commented Apr 22, 2022

hi,
Everything is correct in debug and profile mode and works well, but in the release version, after hitting the download button, the program crashes and that's it!

@J-Dark
Copy link

J-Dark commented Apr 26, 2022

Same issue for me on Android.
It works in debug mode but not in release builds where it crashes after hitting the download button.
Works fine on iOS

Edit: Actually for me the issue only occurs from obfuscated release build. it could be the same as #614 (but I'm on version 1.7.3)

@J-Dark
Copy link

J-Dark commented Apr 27, 2022

I missed this in the new readme file:
@pragma('vm:entry-point') must be placed above the callback function to avoid tree shaking in release mode for Android.
Now, for me, it's working even in obfuscated release builds.

@d9media
Copy link

d9media commented Apr 27, 2022

I have pragma present (latest version flutter_downloader) and it still crashes even without obfuscation

I had to put

@pragma('vm:entry-point')

in my downloadCallback method. now it works

@bartekpacia
Copy link
Collaborator

@J-Dark's solution is correct.

Closing :)

@Shubham-Narkhede
Copy link

I missed this in the new readme file: @pragma('vm:entry-point') must be placed above the callback function to avoid tree shaking in release mode for Android. Now, for me, it's working even in obfuscated release builds.

Can you please add any screenshot exactly where to put this line?

@bartekpacia @J-Dark @d9media @sh4msi

@bartekpacia
Copy link
Collaborator

bartekpacia commented Nov 22, 2022

@Shubham-Narkhede Let me know if the below snippet helps you:

@pragma('vm:entry-point')
void downloadCallback(String id, DownloadTaskStatus status, int progress) {
  // body can be anything, this is just copy-paste from my project
  debugPrint(
    'DatafilesScreen: downloader callback on background isolate: '
    'task: $id, '
    'status: $status, '
    'progress $progress',
  );

  final send = ui.IsolateNameServer.lookupPortByName('downloader_send_port');
  send?.send([id, status, progress]);
}

FlutterDownloader.registerCallback(downloadCallback);

@Shubham-Narkhede
Copy link

@Shubham-Narkhede Let me know if the below snippet helps you:

@pragma('vm:entry-point')
void downloadCallback(String id, DownloadTaskStatus status, int progress) {
  // body can be anything, this is just copy-paste from my project
  debugPrint(
    'DatafilesScreen: downloader callback on background isolate: '
    'task: $id, '
    'status: $status, '
    'progress $progress',
  );

  final send = ui.IsolateNameServer.lookupPortByName('downloader_send_port');
  send?.send([id, status, progress]);
}

FlutterDownloader.registerCallback(downloadCallback);

T

@Shubham-Narkhede Let me know if the below snippet helps you:

@pragma('vm:entry-point')
void downloadCallback(String id, DownloadTaskStatus status, int progress) {
  // body can be anything, this is just copy-paste from my project
  debugPrint(
    'DatafilesScreen: downloader callback on background isolate: '
    'task: $id, '
    'status: $status, '
    'progress $progress',
  );

  final send = ui.IsolateNameServer.lookupPortByName('downloader_send_port');
  send?.send([id, status, progress]);
}

FlutterDownloader.registerCallback(downloadCallback);

Thanks

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

No branches or pull requests

5 participants