-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Breaking Change Request] [vm] Deprecate and remove dart native extensions #45451
Copy link
Copy link
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.breaking-change-requestThis tracks requests for feedback on breaking changesThis tracks requests for feedback on breaking changeslegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.breaking-change-requestThis tracks requests for feedback on breaking changesThis tracks requests for feedback on breaking changeslegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Summary
Dart Native Extensions is a mechanism for loading native code into a running Dart program and binding Dart methods to native implementatations.
It consists of the following parts:
dart-ext:...import scheme which instructs VM to load a native library;nativekeyword which specifies that a function has a native implementation;runtime/include/dart_api.h) which can be used to reflectively inspect and mutate the state of the Dart program;Currently native extensions only really work in a standalone Dart VM - Flutter embedder hides VM C API symbols and does not allow developers to interact with Dart through Dart VM APIs.
Relience on C API means that:
@pragma('vm:entry-point')which in turn disables treeshaking).dart:ffiwas designed to not have these problems - be both more effecient and more AOT friendly.dart:ffiworks in standalone VM as well as Flutter.From our perspective it does not make sense to maintain two completely different approaches to binding Dart code to native especially given that one of them is obviously superior. We don't want more packages using native extensions to appear in the ecosystem and we want to push all new Dart users to use
dart:ffi.We propose the following:
dart-ext:import.dart-ext:imports and hide Dart VM C API symbols from standalonedartbinary shipped with SDKImpact
All packages that use
dart-ext:will be broken by the release. We will work to estimate the impact, but we consider it to be very small because none of the Flutter compatible packages will be affected, as Flutter does not support this mechanism in the first place.TODO