amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Isolate Support

Open tyllark opened this issue 1 year ago • 0 comments

Description

Currently Amplify does not support running in isolates such as:

Amplify need to be configured in each isolate which has a large memory footprint and will fail when configuring native resources multiple times (ex. DataStore).

Some plugins (ex. push notifications) can only run on the main isolate due to platform limitations.

WorkManager can stop the Flutter engine which deinitializes all of our native plugins thus breaking most packages.

Categories

  • [ ] Analytics
  • [ ] API (REST)
  • [ ] API (GraphQL)
  • [ ] Auth
  • [ ] Authenticator
  • [ ] DataStore
  • [ ] Notifications (Push)
  • [ ] Storage

Steps to Reproduce

//Spawning an isolate final jsonData = await Isolate.run(_someFuction);

//WorkManager Example @pragma('vm:entry-point') void callbackDispatcher() { Workmanager().executeTask((task, inputData) async { safePrint("executeTask"); return Future.value(true); }); }

void main() async { WidgetsFlutterBinding.ensureInitialized();

final auth = AmplifyAuthCognito(); final pushPlugin = AmplifyPushNotificationsPinpoint(); await Amplify.addPlugins([auth, pushPlugin]); await Amplify.configure(amplifyconfig);

Amplify.Notifications.Push.onTokenReceived.listen((event) { safePrint("onTokenReceived: $event"); });

Workmanager().initialize(callbackDispatcher, isInDebugMode: true); Workmanager().registerOneOffTask("test", "test");

runApp(const MyApp()); }

Screenshots

No response

Platforms

  • [X] iOS
  • [X] Android
  • [X] Web
  • [X] macOS
  • [X] Windows
  • [X] Linux

Flutter Version

2.34.2

Amplify Flutter Version

2.3.0

Deployment Method

Amplify CLI

Schema

No response

tyllark avatar Aug 15 '24 18:08 tyllark