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

Isolate Support #5302

Open
6 of 14 tasks
tyllark opened this issue Aug 15, 2024 · 0 comments
Open
6 of 14 tasks

Isolate Support #5302

tyllark opened this issue Aug 15, 2024 · 0 comments
Labels
feature-request A request for a new feature or an enhancement to an existing API or category.

Comments

@tyllark
Copy link
Member

tyllark commented Aug 15, 2024

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

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

2.34.2

Amplify Flutter Version

2.3.0

Deployment Method

Amplify CLI

Schema

No response

@tyllark tyllark added the feature-request A request for a new feature or an enhancement to an existing API or category. label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a new feature or an enhancement to an existing API or category.
Projects
None yet
Development

No branches or pull requests

1 participant