172 Commits

Author SHA1 Message Date
Chinmay Garde
570231b7ab
Specify the packages file path when running engine dart tests. (#5005) 2018-04-13 16:17:38 -07:00
Chinmay Garde
4e0fbb6f01
If the test specifies a .dill file, dont make the engine interpret is as source. (#5002) 2018-04-13 15:07:28 -07:00
Chinmay Garde
58e84c8bf0
Re-land "Support multiple shells in a single process. (#4932)" (#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit 723c7d01439da4261bc836075fb55651ce9e7f03.
2018-04-13 13:48:15 -07:00
Vyacheslav Egorov
723c7d0143
Revert "Re-land "Support multiple shells in a single process. (#4932)" (#4977)" (#4981)
This reverts commit a3327bff86800b3e654a2988fa7e6049edeb679c.
2018-04-12 18:28:55 +02:00
Chinmay Garde
a3327bff86
Re-land "Support multiple shells in a single process. (#4932)" (#4977)
This reverts commit 9199b40f2a2a6e448cd251de44e020ec3b75002d.
2018-04-11 15:41:23 -07:00
Chinmay Garde
9199b40f2a
Revert "Support multiple shells in a single process. (#4932)" (#4964)
This reverts commit 6baff4c821350bbcb64e7d029574b567f3801a1a.
2018-04-10 15:28:43 -07:00
Chinmay Garde
6baff4c821
Support multiple shells in a single process. (#4932)
* Support multiple shells in a single process.

The Flutter Engine currently works by initializing a singleton shell
instance. This shell has to be created on the platform thread. The shell
is responsible for creating the 3 main threads used by Flutter (UI, IO,
GPU) as well as initializing the Dart VM. The shell, references to task
runners of the main threads as well as all snapshots used for VM
initialization are stored in singleton objects. The Flutter shell only
creates the threads, rasterizers, contexts, etc. to fully support a
single Flutter application. Current support for multiple Flutter
applications is achieved by making multiple applications share the same
resources (via the platform views mechanism).

This scheme has the following limitations:

* The shell is a singleton and there is no way to tear it down. Once you
  run a Flutter application in a process, all resources managed by it
  will remain referenced till process termination.
* The threads on which the shell performs its operations are all
  singletons. These threads are never torn down and multiple Flutter
  applications (if present) have to compete with one another on these
  threads.
* Resources referenced by the Dart VM are leaked because the VM isn't
  shutdown even when there are no more Flutter views.
* The shell as a target does not compile on Fuchsia. The Fuchsia content
  handler uses specific dependencies of the shell to rebuild all the
  shell dependencies on its own. This leads to differences in frame
  scheduling, VM setup, service protocol endpoint setup, tracing, etc..
  Fuchsia is very much a second class citizen in this world.
* Since threads and message loops are managed by the engine, the engine
  has to know about threading and platform message loop interop on each
  supported platform.

Specific updates in this patch:

* The shell is no longer a singleton and the embedder holds the unique
  reference to the shell.
* Shell setup and teardown is deterministic.
* Threads are no longer managed by the shell. Instead, the shell is
  given a task runner configuration by the embedder.
* Since the shell does not own its threads, the embedder can control
  threads and the message loops operating on these threads. The shell is
  only given references to the task runners that execute tasks on these
  threads.
* The shell only needs task runner references. These references can be
  to the same task runner. So, if the embedder thinks that a particular
  Flutter application would not need all the threads, it can pass
  references to the same task runner. This effectively makes Flutter
  application run in single threaded mode. There are some places in the
  shell that make synchronous calls, these sites have been updated to
  ensure that they don’t deadlock.
* The test runner and the headless Dart code runner are now Flutter
  applications that are effectively single threaded (since they don’t
  have rendering concerns of big-boy Flutter application).
* The embedder has to guarantee that the threads and outlive the shell.
  It is easy for the embedder to make that guarantee because shell
  termination is deterministic.
* The embedder can create as many shell as it wants. Typically it
  creates a shell per Flutter application with its own task runner
  configuration. Most embedders obtain these task runners from threads
  dedicated to the shell. But, it is entirely possible that the embedder
  can obtain these task runners from a thread pool.
* There can only be one Dart VM in the process. The numerous shell
  interact with one another to manage the VM lifecycle. Once the last
  shell goes away, the VM does as well and hence all resources
  associated with the VM are collected.
* The shell as a target can now compile and run on Fuchsia. The current
  content handler has been removed from the Flutter engine source tree
  and a new implementation has been written that uses the new shell
  target.
* Isolate management has been significantly overhauled. There are no
  owning references to Dart isolates within the shell. The VM owns the
  only strong reference to the Dart isolate. The isolate that has window
  bindings is now called the root isolate. Child isolates can now be
  created from the root isolate and their bindings and thread
  configurations are now inherited from the root isolate.
* Terminating the shell terminates its root isolates as well as all the
  isolates spawned by this isolate. This is necessary be shell shutdown
  is deterministic and the embedder is free to collect the threads on
  which the isolates execute their tasks (and listen for mircrotasks
  flushes on).
* Launching the root isolate is now significantly overhauled. The shell
  side (non-owning) reference to an isolate is now a little state
  machine and illegal state transitions should be impossible (barring
  construction issues). This is the only way to manage Dart isolates in
  the shell (the shell does not use the C API is dart_api.h anymore).
* Once an isolate is launched, it must be prepared (and hence move to
  the ready phase) by associating a snapshot with the same. This
  snapshot can either be a precompiled snapshot, kernel snapshot, script
  snapshot or source file. Depending on the kind of data specified as a
  snapshot as well as the capabilities of the VM running in the process,
  isolate preparation can fail preparation with the right message.
* Asset management has been significantly overhauled. All asset
  resolution goes through an abstract asset resolver interface. An asset
  manager implements this interface and manages one or more child asset
  resolvers. These asset resolvers typically resolve assets from
  directories, ZIP files (legacy FLX assets if provided), APK bundles,
  FDIO namespaces, etc…
* Each launch of the shell requires a separate and fully configured
  asset resolver. This is necessary because launching isolates for the
  engine may require resolving snapshots as assets from the asset
  resolver. Asset resolvers can be shared by multiple launch instances
  in multiple shells and need to be thread safe.
* References to the command line object have been removed from the
  shell. Instead, the shell only takes a settings object that may be
  configured from the command line. This makes it easy for embedders and
  platforms that don’t have a command line (Fuchsia) to configure the
  shell. Consequently, there is only one spot where the various switches
  are read from the command line (by the embedder and not the shell) to
  form the settings object.
* All platform now respect the log tag (this was done only by Android
  till now) and each shell instance have its own log tag. This makes
  logs from multiple Flutter application in the same process (mainly
  Fuchsia) more easily decipherable.
* The per shell IO task runner now has a new component that is
  unfortunately named the IOManager. This component manages the IO
  GrContext (used for asynchronous texture uploads) that cooperates with
  the GrContext on the GPU task runner associated with the shell. The
  IOManager is also responsible for flushing tasks that collect Skia
  objects that reference GPU resources during deterministic shell
  shutdown.
* The embedder now has to be careful to only enable Blink on a single
  instance of the shell. Launching the legacy text layout and rendering
  engine multiple times is will trip assertions. The entirety of this
  runtime has been separated out into a separate object and can be
  removed in one go when the migration to libtxt is complete.
* There is a new test target for the various C++ objects that the shell
  uses to interact with the Dart VM (the shell no longer use the C API
  in dart_api.h). This allows engine developers to test VM/Isolate
  initialization and teardown without having the setup a full shell
  instance.
* There is a new test target for the testing a single shell instances
  without having to configure and launch an entire VM and associated
  root isolate.
* Mac, Linux & Windows used to have different target that created the
  flutter_tester referenced by the tool. This has now been converted
  into a single target that compiles on all platforms.
* WeakPointers vended by the fml::WeakPtrFactory(notice the difference
  between the same class in the fxl namespace) add threading checks on
  each use. This is enabled by getting rid of the “re-origination”
  feature of the WeakPtrFactory in the fxl namespace. The side effect of
  this is that all non-thread safe components have to be created, used
  and destroyed on the same thread. Numerous thread safety issues were
  caught by this extra assertion and have now been fixed.
  * Glossary of components that are only safe on a specific thread (and
    have the fml variants of the WeakPtrFactory):
    * Platform Thread: Shell
    * UI Thread: Engine, RuntimeDelegate, DartIsolate, Animator
    * GPU Thread: Rasterizer, Surface
    * IO Thread: IOManager

This patch was reviewed in smaller chunks in the following pull
requests. All comments from the pulls requests has been incorporated
into this patch:

* flutter/assets: https://github.com/flutter/engine/pull/4829
* flutter/common: https://github.com/flutter/engine/pull/4830
* flutter/content_handler: https://github.com/flutter/engine/pull/4831
* flutter/flow: https://github.com/flutter/engine/pull/4832
* flutter/fml: https://github.com/flutter/engine/pull/4833
* flutter/lib/snapshot: https://github.com/flutter/engine/pull/4834
* flutter/lib/ui: https://github.com/flutter/engine/pull/4835
* flutter/runtime: https://github.com/flutter/engine/pull/4836
* flutter/shell: https://github.com/flutter/engine/pull/4837
* flutter/synchronization: https://github.com/flutter/engine/pull/4838
* flutter/testing: https://github.com/flutter/engine/pull/4839
2018-04-10 14:57:02 -07:00
Jason Simmons
ca57221606
Load kernel files from the script URI in the isolate create callback (#4828)
Fixes https://github.com/flutter/flutter/issues/15731
2018-03-20 17:25:22 -07:00
Zachary Anderson
5e83371a06
Remove some unneeded profiling flags (#4827) 2018-03-20 15:48:41 -07:00
Ryan Macnak
e3197abe83
Reapply "Roll Dart to f1ebe2bd5cfcb6b522e5b4fd406cdabb1a2d2091." (#4809) 2018-03-19 11:22:23 -07:00
Alhaad Gokhale
8e1da69c31
Revert "Roll Dart to f1ebe2bd5cfcb6b522e5b4fd406cdabb1a2d2091. (#4800) (#4805)" (#4807)
This reverts commit 1348ab5b63adc18148f161876a4b1cacd5ec0779.
2018-03-19 09:51:41 -07:00
mikejurka
1348ab5b63
Roll Dart to f1ebe2bd5cfcb6b522e5b4fd406cdabb1a2d2091. (#4800) (#4805) 2018-03-16 17:08:06 -07:00
mikejurka
9e0f015d96
Revert "Roll Dart to f1ebe2bd5cfcb6b522e5b4fd406cdabb1a2d2091. (#4800)" (#4803)
This reverts commit c24e2850d513cb1dab85322955f712e61ca71297.
2018-03-16 16:22:41 -07:00
Ryan Macnak
c24e2850d5
Roll Dart to f1ebe2bd5cfcb6b522e5b4fd406cdabb1a2d2091. (#4800) 2018-03-16 12:17:38 -07:00
Zachary Anderson
c609dcdd3c
[fuchsia] Fix AOT debug builds (#4787) 2018-03-14 19:19:15 +01:00
Jason Simmons
07e64fd60a
Do not free the buffer owned by the kernel_data vector (#4753)
Fixes https://github.com/flutter/flutter/issues/14947
2018-03-07 14:21:15 -08:00
Sarah Zakarias
a00f8e8bc0
Read assets out of APK on Android (#4742) 2018-03-05 14:09:45 +01:00
Ryan Macnak
0d4e72e86f
[fuchsia] Place Observatory in the runner's package instead of linking it in. (#4719)
This allows blobfs to deduplicate it across {dart,flutter}_{jit,aot}_runner.
2018-02-27 16:45:52 -08:00
Vyacheslav Egorov
bacb388fda
Switch on --sync-async in Dart 2 mode (#4686) 2018-02-27 09:44:27 +01:00
Siva
19e8d9b2bf
Fix strong flag setting (#4683)
* Turn on strong mode by default when a platform file is present in the
bundle instead of using a flag passed into the engine which might not be
true when we invoke an installed app.

* - Roll dart to version fe96de2858f078e4ad04f8f30640184bf3d8102d

* Update license file.
2018-02-15 11:02:31 -08:00
Alexander Markov
04933f61e9
Make native wrapper classes non-abstract (#4607)
* Make native wrapper classes non-abstract as they are instantiated from native code
* Make constructors of native wrapper classes private
2018-02-09 12:17:36 -08:00
Ryan Macnak
c210d62a6c
[fuchsia] Add missing AOT entry points for FromFileResult and MapResult. (#4649) 2018-02-08 09:34:19 -08:00
Zachary Anderson
76d4928b05
Reland: [fuchsia] Enable running from source packages (#4634)
This relands https://github.com/flutter/engine/pull/4629 with a
tonic roll to fix the build.
2018-02-06 10:08:24 -08:00
Jason Simmons
c8bf22552e
Fix an improper deletion of DirectoryAssetBundle when creating isolates (#4637) 2018-02-05 17:33:59 -08:00
Yegor
6dd49f0695
iOS a11y text entry (~70% of it) (#4575)
* implement iOS text field editing in a11y mode

* address Chinmay's comments

* replace node in child list when changing type
2018-02-05 15:14:13 -08:00
Zachary Anderson
151bb37435
Revert "[fuchsia] Enable running from source packages (#4629)" (#4632)
This reverts commit 8f638591e97b350962001f5af38d2464421ec3dc.
2018-02-02 22:38:49 -08:00
Zachary Anderson
8f638591e9
[fuchsia] Enable running from source packages (#4629) 2018-02-02 15:43:21 -08:00
Zachary Anderson
d5338ed143
[fuchsia] Set up the namespace in dart:zircon (#4628) 2018-02-01 22:47:01 -08:00
Siva Chandra
2b398ee227 Roll Dart to 93d8c9fe2a2c22dc95ec85866af108cfab71ad06. (#4558)
* Roll Dart to 93d8c9fe2a2c22dc95ec85866af108cfab71ad06.

* Fix analyzer nits

* Try to pin dependency for tools/licenses to convert 2.0.1. Add verbose flag to pub get

* Pin dart to dev.16 to overcome pub issue

* Revert "Try to pin dependency for tools/licenses to convert 2.0.1. Add verbose flag to pub get"

This reverts commit d525a83f4494a511996226d328a5208d4651d46e as it is no
longer needed, was added to diagnose the problem, which turned out to be
a problem with pub in latest dart dev release.

* Fix license hash

* Reintroduce api methods and tests
2018-01-18 12:35:09 -08:00
Siva
0f0b144b03
Add support for --strong option in the engine, create a strong mode version of the platform file (#4504)
* Add a --strong option to the front end server so we can use strong mode with preview-dart-2.

* Plumb the --strong option through the dart controller into the VM.

* - Build a strong version of platform.dill for use with the engine.
- Fix a strong mode static error in the assert statement

* Enable asserts when running debug version even in strong mode.

* Use the correct platform dill file for linking when doing the aot builds.

* Fix formatting issue.
2018-01-03 16:52:24 -08:00
Alexander Markov
37789650cb
Enable Dart 2.0 fixed-size integers in Flutter (#4501) 2018-01-02 14:34:15 -08:00
Zachary Anderson
ea2ce27baa Revert "Ensure language and country codes are not empty" (#4494) 2017-12-22 15:00:42 -08:00
Zachary Anderson
c0d60f17f7
Ensure language and country codes are not empty (#4492) 2017-12-22 10:09:02 -08:00
Sarah Zakarias
0890783d5b
Add zip asset store to AssetFontSelector (#4475) 2017-12-19 12:28:03 +01:00
Brian Osman
d65b521b41
Fix formatting (#4473) 2017-12-18 13:21:32 -05:00
Sarah Zakarias
1c46319677
Read platform kernel blob from asset directory instead of FLX (#4471) 2017-12-18 13:15:01 +01:00
Sarah Zakarias
0545882650
Select fonts from asset directory instead of FLX (#4464) 2017-12-18 09:01:56 +01:00
Sarah Zakarias
f04c5715ce
Add missing include (#4454) 2017-12-13 14:29:14 +01:00
Sarah Zakarias
8cfab93439
Add #define's in dart_init.cc (#4453) 2017-12-13 14:13:02 +01:00
Sarah Zakarias
4cbe26dd37
Handle Flutter assets outside FLX (#4343) 2017-12-13 10:55:24 +01:00
Zachary Anderson
df18819048
Fix Platform.localeName by setting _Platform._localeClosure (#4450) 2017-12-12 15:01:13 -08:00
Michael Goderbauer
e07eafae1d
Roll forward: Parameters for SemanticActions; a11y text selection (#4452)
Reverts the revert in #4448 with fixes to pass on the bot.

This change will require framework changes in flutter/flutter#13490.
2017-12-12 14:25:45 -08:00
Michael Goderbauer
056fd4597f
Revert " Add parameters to SemanticActions; implement extend selection for a11y (#4444)" (#4448)
This reverts commit 59c3a37e6436d60381d9708113228c83ccc6b7f9.
2017-12-12 10:53:15 -08:00
Michael Goderbauer
59c3a37e64
Add parameters to SemanticActions; implement extend selection for a11y (#4444) 2017-12-12 10:06:04 -08:00
Vyacheslav Egorov
edaecdc8b8 Update VM entry points list to include some previous omitted entries. (#4440)
This fixes obfuscated snapshot mode.
2017-12-11 11:27:23 -08:00
Ben Konyi
74a2d90530
Changes to assets/ build/ flow/ runtime/ and shell/ to allow for compilation on Windows (#4407)
Made changes to assets/ build/ flow/ runtime/ and shell/ to allow for
compilation on Windows.
2017-11-30 19:47:20 -05:00
Zachary Anderson
5f9c8522dd
Roll Dart to 3ee0a4284203ebc6991c78054583a7c02dc8faf9 (#4378) 2017-11-21 12:16:34 -08:00
amirh
25912b8482
add ui.Codec and ui.FrameInfo constructors to the dart_vm_entry_points.txt (#4371) 2017-11-16 16:49:20 -08:00
Zachary Anderson
0e564957ac
Roll Dart back to 4dd4fd745e588eef64b8d85811d847ab72633cb7 (#4370) 2017-11-16 09:24:13 -08:00
Ian McKellar
d917c35e72
Allow Flutter apps on Fuchsia to shut down cleanly (#4366)
The UIDartState is now always owned by the isolate and always freed in
the isolate cleanup callback.

In the isolate shutdown callback, if the isolate being shut down is the
main isolate, the RuntimeController is informed which in turn notifies
the RuntimeHolder and thus the ApplicationControllerImpl. The
ApplicationControllerImpl tears down the whole Flutter application.

This fixes Fuchsia bug: MI4-328
2017-11-15 13:28:21 -08:00