Skip to content

@pragma('vm:entry-point') requirement for isolate entry points#45

Open
alnitak wants to merge 1 commit intoflutter:mainfrom
alnitak:main
Open

@pragma('vm:entry-point') requirement for isolate entry points#45
alnitak wants to merge 1 commit intoflutter:mainfrom
alnitak:main

Conversation

@alnitak
Copy link
Copy Markdown

@alnitak alnitak commented Mar 14, 2026

When spawning an isolate using Isolate.spawn(), the entry point callback function is invoked dynamically by the Dart VM. Unlike regular function calls that the compiler can track through static analysis, the VM looks up this function at runtime to start the isolate's execution.

This means that during tree-shaking (a process where the compiler removes unused code to reduce app size), the entry point function may be incorrectly identified as "dead code" and removed from the compiled output. This typically only manifests in release builds, causing the app to crash or fail silently when trying to spawn the isolate.

Solution

Add the @pragma('vm:entry-point') annotation to all isolate entry point functions.

Ref: pragmas

fixes #46

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read the [Flutter Style Guide] recently, and have followed its advice.
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@pragma('vm:entry-point') requirement for isolate entry points

1 participant