rmawatson / flutter_isolate

Launch an isolate that can use flutter plugins.
MIT License
262 stars 80 forks source link

library 'package:flutter_isolate/src/compute.dart' not found #123

Closed brun0xon closed 1 year ago

brun0xon commented 1 year ago

flutter_isolate: ^2.0.3 Flutter 3.3.3 Android 12

Hello. Tried to use flutterCompute() function. In debug it perfectly works, but when dealing with release, then getting this error: [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_isolate/src/compute.dart' not found.

A function, that passed to flutterCompute(), is top-level and annotated with @pragma('vm:entry-point')

@pragma('vm:entry-point')
Future<bool> cacheData(Map<String, dynamic> params) async {...}

...
flutterCompute(cacheData, {'environment': 1});
nmfisher commented 1 year ago

Did you decorate your function with @pragma('vm:entry-point')

?

On 5 Oct 2022, at 7:51 PM, brun0xon @.***> wrote:

 flutter_isolate: ^2.0.3 Flutter 3.3.3 Android 12

Hello. Tried to use flutterCompute() function. In debug it perfectly works, but when dealing with release, then getting this error: [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_isolate/src/compute.dart' not found.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

brun0xon commented 1 year ago

Did you decorate your function with @pragma('vm:entry-point')

Yes, I wrote an example above

nmfisher commented 1 year ago

Can you reproduce this in a standalone sample project?

Also it might be worth trying the following release configuration in build.gradle:

release {
        shrinkResources false // ADD THIS
        minifyEnabled false // ADD THIS
}

I've recently (> Flutter 3.x) started having trouble with plugins on Android not working in in release mode. Seems the plugin registration method lookup isn't working due to some kind of symbol minification.

jaysignorello commented 1 year ago

Also having similar issues with flutterCompute in flutter 3.3.4 and iOS. The call just hangs and never completes. Worked fine with flutter 3.0.5 and earlier version of this package. Works fine in debug/profile, but stops working correctly in release. function is annotated with @pragma('vm:entry-point')

abdalmonem commented 1 year ago

Can you reproduce this in a standalone sample project?

Also it might be worth trying the following release configuration in build.gradle:

release {
        shrinkResources false // ADD THIS
        minifyEnabled false // ADD THIS
}

I've recently (> Flutter 3.x) started having trouble with plugins on Android not working in in release mode. Seems the plugin registration method lookup isn't working due to some kind of symbol minification.

i also facing the same issue , and i do added 'shrinkResources' and 'minifyEnabled' but isnt solve

brun0xon commented 1 year ago

i do added 'shrinkResources' and 'minifyEnabled' but isnt solve

+1

brun0xon commented 1 year ago

Solved by adding @pragma('vm:entry-point') to functions flutterCompute() and _isolateMain() in compute.dart file. Please, publish fix as soon as possible.

abdalmonem commented 1 year ago

@brun0xon if you mean addding @pragma('vm:entry-point') to the top level function i would say its also doesnt work edit: i get it , and correct edit the source flutterCompute and _isolateMain methods with a @pragma('vm:entry-point') at the top of them solve the issue

jopmiddelkamp commented 1 year ago

The project below results in the error when building on Flutter 3.3.6 and running in release mode. flutter_isolate_issue.zip

Solved by adding @pragma('vm:entry-point') to functions flutterCompute() and _isolateMain() in compute.dart file. Please, publish fix as soon as possible.

This seems to solve the issue in the example above. When I copy the code from the master branch into the project and add the @pragma on those methods everything seems to work fine.

ziggycrane commented 1 year ago

How is it possible this hasn't been solved for more than a month even though people here showed how to fix it?

nmfisher commented 1 year ago

@ziggycrane are you offering to pay me to fix this?

nmfisher commented 1 year ago

Merged in #126