rmawatson/flutter_isolate

Library not found in ISO release mode

Opened this issue · 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(),
  ));
}

Where are you spawning your isolate?

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

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?)

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

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.

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.

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.

Maybe it is related to this?
dart-lang/sdk#49181

This PR should fix it. #118