Ensure root isolate create callback is invoked before the isolate is in the running phase. (#22041)

Embedders that have access to the Dart native API (only Fuchsia now) may perform
library setup in the isolate create callback. The engine used to depend on the
fact the root isolate entrypoint is invoked in the next iteration of message
loop (via the `_startIsolate` trampoline in `isolate_patch.dart`) to ensure that
library setup occur before the main entrypoint was invoked. However, due to
differences in the way in which message loops are setup in Fuchsia, this
entrypoint was run before the callback could be executed. Dart code on Fuchsia
also has the ability to access the underlying event loops directly. This patch
moves the invocation of the create callback to before user dart code has a
chance to run. This difference in behavior on Fuchsia became an issue when the
isolate initialization was reworked in https://github.com/flutter/engine/pull/21820
for null-safety.

Another issue was discovered in that the callback was being invoked twice, I
fixed that too and added a test.

Fixes https://github.com/flutter/flutter/issues/68732
5 files changed
tree: cd42e7feab688f21c2404a34ff87e7176cd4855d
  1. .github/
  2. assets/
  3. benchmarking/
  4. build/
  5. ci/
  6. common/
  7. docs/
  8. e2etests/
  9. examples/
  10. flow/
  11. flutter_frontend_server/
  12. fml/
  13. lib/
  14. runtime/
  15. shell/
  16. sky/
  17. testing/
  18. third_party/
  19. tools/
  20. vulkan/
  21. web_sdk/
  22. .cirrus.yml
  23. .clang-format
  24. .clang-tidy
  25. .gitattributes
  26. .gitignore
  27. analysis_options.yaml
  28. AUTHORS
  29. BUILD.gn
  30. CONTRIBUTING.md
  31. DEPS
  32. Doxyfile
  33. LICENSE
  34. README.md
README.md

Flutter Engine

Build Status - Cirrus

Flutter is Google's mobile app SDK for crafting high-quality native interfaces in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.

The Flutter Engine is a portable runtime for hosting Flutter applications. It implements Flutter's core libraries, including animation and graphics, file and network I/O, accessibility support, plugin architecture, and a Dart runtime and compile toolchain. Most developers will interact with Flutter via the Flutter Framework, which provides a modern, reactive framework, and a rich set of platform, layout and foundation widgets.

If you want to run/contribute to Flutter Web engine, more tooling can be found at felt. This is a tool written to make web engine development experience easy.

If you are new to Flutter, then you will find more general information on the Flutter project, including tutorials and samples, on our Web site at Flutter.dev. For specific information about Flutter's APIs, consider our API reference which can be found at the docs.flutter.dev.

Flutter is a fully open source project, and we welcome contributions. Information on how to get started can be found at our contributor guide.