flutter_isolate icon indicating copy to clipboard operation
flutter_isolate copied to clipboard

Library not found in ISO release mode

Open mal33k-eden opened this issue 2 years ago • 9 comments

Hello i am using the flutter_isolate plugin to call some apis and update sqflite db on the mobile app.Everything works as expected when tested in debug mode but when in release mode i get this errors in xcode:


2022-07-05 15:01:03.289687-0700 Runner[910:32263] [VERBOSE-2:shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_isolate/flutter_isolate.dart' not found.
2022-07-05 15:01:03.289804-0700 Runner[910:32263] [VERBOSE-2:dart_isolate.cc(669)] Could not resolve main entrypoint function.
2022-07-05 15:01:03.289840-0700 Runner[910:32263] [VERBOSE-2:dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
2022-07-05 15:01:03.290833-0700 Runner[910:32263] [VERBOSE-2:runtime_controller.cc(385)] Could not create root isolate.
2022-07-05 15:01:03.290886-0700 Runner[910:32263] [VERBOSE-2:shell.cc(604)] Could not launch engine with configuration.

i am not sure what the challenge is. Screenshot 2022-07-05 at 15 23 39

this is how my main() looks like

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  DartPluginRegistrant.ensureInitialized();
  await localTokenManager.ensureFreshInstall();
  await dotenv.load();
  HttpOverrides.global = MyHttpOverrides();
  
  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider<AuthProvider>(create: (_) => AuthProvider()),
    ],
    child: SplashScreen(),
  ));
}

mal33k-eden avatar Jul 05 '22 22:07 mal33k-eden

Where are you spawning your isolate?

nmfisher avatar Jul 06 '22 09:07 nmfisher

i am spawning it in a service class.

service.dart

class AssetStreamer {
Future<void> refreshAssetBalance(String s) async { 
    try {
      await FlutterIsolate.spawn(updateAssetBalance, null); 
      
      notifyListeners();
      // ignore: empty_catches
    } catch (e) {
      print(e);
    }
  }
}

i am calling AssetStreamer().refreshAssetBalance in the initState of certain views

mal33k-eden avatar Jul 06 '22 16:07 mal33k-eden

Can you reproduce this in a standalone project? It looks like a local project issue (have you tried running flutter clean and running outside Xcode?)

nmfisher avatar Jul 08 '22 14:07 nmfisher

@mal33k-eden Any update? Will close unless response received.

nmfisher avatar Jul 20 '22 01:07 nmfisher

I have the same issue trying to use this as well on android in release mode, debug and profile work great. Release or release via flutter build apk has the same error:

E/flutter ( 6069): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_isolate/flutter_isolate.dart' not found. E/flutter ( 6069): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function. E/flutter ( 6069): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint. E/flutter ( 6069): [ERROR:flutter/runtime/runtime_controller.cc(386)] Could not create root isolate.

I'll try to make a standalone project.

fred-derf avatar Aug 19 '22 21:08 fred-derf

This happens with any example, even the simplest possible example when running in release mode on a physical android device but doesn't happen in flutter channel stable.

Flutter channel beta and master are currently broken and will throw this error.

fred-derf avatar Aug 20 '22 15:08 fred-derf

Obfuscation also causes the same error with flutter channel stable:

E/flutter (10321): [ERROR:flutter/shell/common/shell.cc(93)] Dart Unhandled Exception: NoSuchMethodError: No top-level getter '_Lee' declared. E/flutter (10321): Receiver: top-level E/flutter (10321): Tried calling: _Lee, stack trace: Warning: This VM has been configured to produce stack traces that violate the Dart standard. E/flutter (10321): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** E/flutter (10321): pid: 10321, tid: 10361, name Unknown E/flutter (10321): build_id: '7f1b36b85f33f8c8d348edb2f03a7930' E/flutter (10321): isolate_dso_base: 8e580000, vm_dso_base: 8e580000 E/flutter (10321): isolate_instructions: 8e75bbd0, vm_instructions: 8e758000 E/flutter (10321): #00 abs 8e77fcab virt 001ffcab _kDartIsolateSnapshotInstructions+0x240db E/flutter (10321): E/flutter (10321): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function. E/flutter (10321): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint. E/flutter (10321): [ERROR:flutter/runtime/runtime_controller.cc(382)] Could not create root isolate. E/flutter (10321): [ERROR:flutter/shell/common/shell.cc(600)] Could not launch engine with configuration.

fred-derf avatar Aug 20 '22 20:08 fred-derf

Maybe it is related to this? https://github.com/dart-lang/sdk/issues/49181

srmncnk avatar Sep 05 '22 13:09 srmncnk

This PR should fix it. https://github.com/rmawatson/flutter_isolate/pull/118

srmncnk avatar Sep 06 '22 09:09 srmncnk