47 Commits

Author SHA1 Message Date
Ben Konyi
8d8d91bfc3
IsolateNameServer reland (#5519)
* Reland "Added IsolateNameServer functionality (#5410)"

This reverts commit c3976b3c7183f479717bffed3f640fb92afbd3dc.

* Fixed issue with isolate_name_server_test which caused test to timeout

* Disabled thread_annotations on Android as they aren't supported in the
NDK headers for std::mutex. Readded thread annotations to
IsolateNameServer.
2018-06-13 11:57:10 -07:00
Ben Konyi
c3976b3c71
Revert "Added IsolateNameServer functionality (#5410)" (#5516)
This reverts commit 61a2d129cfc8c52cf1ff59b03bccf67d9b07af63.
2018-06-12 17:03:13 -07:00
Ben Konyi
61a2d129cf
Added IsolateNameServer functionality (#5410)
* Added IsolateNameServer functionality, which allows for the association
of string names with isolate SendPort ids that can be used to establish
inter-isolate communications.
2018-06-12 15:50:48 -07:00
Chinmay Garde
5441ee79ff
Allow embedders to specify a custom advisory URI and entrypoint. (#5408)
The Fuchsia embedder wants to specify the application name in the field for the advisory URI. This allows embedders to specify whatever they want.
2018-05-29 15:10:12 -07:00
Ryan Macnak
fb709e25e3
[fuchsia] Plumbing for sharing between AOT snapshots. (#5351) 2018-05-24 13:24:14 -07:00
Chinmay Garde
d97b6d859a
Allow explicit specification of the isolate snapshot. (#5193)
The mobile shells all use the same isolate snapshot. This is also the snapshot used by the service isolate. This works towards a world where the isolate snapshot is no longer a member variable of the DartVM instance. Instead, all snapshots must be specified in the run configuration. For now, the new `Shell::Create` overload will only be used by Fuchsia till I refactor `dart_vm.cc`.

There are no API updates to the mobile shells.
2018-05-07 17:28:31 -07:00
Chinmay Garde
00911b2a85
Don't send platform messages to isolates that are not running. (#5031)
Isolates may be launched and awaiting snapshot association. We don't
want to send such isolates any messages before their "main" method is
called. In such cases, the engine may intercept and store certain
launch specific information.
2018-04-17 17:10:17 -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
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
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
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
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
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
Alexander Aprelev
ec19da1c80 Initialize service isolate from kernel file, rather than from embedded sources. (#4263)
* Read core platform kernel file during Dart initialization.

Currently service isolate is initialized from the source code parsed by VM.
This CL changes it so service isolate created during Dart initialization
is created from the kernel platform.dill file if it is present in the application
bundle. Then this platform kernel file is kept in dart_init module and reused
for application sciprt isolates.

* Reformat and merge

* Use accessor method

* Avoid passing running_from_kernel param. Add TODO for cleanup. Rename param.
2017-10-24 19:37:24 -07:00
Yegor
23f5ccd25c Add alwaysUse24HourFormat and textScaleFactor (#4202)
* systems/settings channel split

* merge textScaleFactor and alwaysUse24HourFormat into flutter/settings channel

* add debugOverrideAlwaysUse24HourFormat

* implement textScaleFactor on iOS

* address comments

* remove debugOverrideAlwaysUse24HourFormat

* clang-format
2017-10-18 16:13:43 -07:00
Siva
5003703330 Fix for issue 12526 (#4218)
* Fix for issue 12526

Ensure that child isolates do not clear the dart_ui_state_ field present in the dart controller.

The commit dd1e0b59ec implemented code to reset the dart_ui_state_ back to null when an isolate was being shutdown to ensure there was no use after free issues when the main isolate exeutes Isolate.current.kill() it however it was also clearning the field when a child isolate was shutdown causing SEGVs later.

* Address code format issues.
2017-10-17 14:47:09 -07:00
gspencergoog
b2a7f4bf8f Add support for system text scale factor. (#4124)
Adds support for system text scale factor, including hooks for Android system settings changes.  iOS hooks will be added in another PR.
2017-09-29 13:19:06 -07:00
Ian McKellar
dd1e0b59ec Support cleaner Dart isolate shutdown handling. (#4121)
If an isolate shuts down (for example if an app calls
Isolate.current.kill()), the UIDartState* on DartController will refer
to a freed object. This wires through notification that the is shutting
down through to the DartController so it can clean up appropriately.

This also makes gives the vm-service isolate an UIDartState* so that
the shutdown callback can behave correctly.
2017-09-19 12:11:05 -07:00
Alexander Aprelev
0e8ffa24e0 Reverting to unblock engine roll (#4109)
* Revert "Make Travis happy again (#4101)"

This reverts commit c99b2559df05f4b5f547d26bb0a61d88809f5564.

* Revert "Support cleaner Dart isolate shutdown handling. (#4096)"

This reverts commit 05751f7be993316057d772e8334a783537e10e26.
2017-09-14 12:10:11 -07:00
Ian McKellar
05751f7be9 Support cleaner Dart isolate shutdown handling. (#4096)
If an isolate shuts down (for example if an app calls
Isolate.current.kill()), the UIDartState* on DartController will refer
to a freed object. This wires through notification that the is shutting
down through to the DartController so it can clean up appropriately.
2017-09-13 10:29:21 -07:00
George Kulakowski
3aa7522c11 Rename ftl to fxl in Fuchsia specific code (#4090) 2017-09-11 15:58:48 -07:00
Ryan Macnak
ffbefaf477 Initial implementation of idle notification. (#4012)
- Assumes only the Dart VM is interested in idle notification.
 - Gives the VM the time remaining in each frame.
 - Gives the VM 100ms if there is no pending frame.

Issue flutter/flutter#9594
2017-09-01 11:11:25 -07:00
Jason Simmons
e687626a65 Incorporate the device pixel ratio when drawing shadows (#3919) 2017-07-24 12:01:43 -07:00
Alexander Aprelev
ba9a525bdc Update Flutter engine kernel-loading logic. (#3886)
* Fix Flutter loading from dill files.

* Remove disable of causal async stacks.

* Include mirrors patch files as they are needed for release/profile gen_snapshot

* Free the bytes

* Add FTL_DCHECK
2017-07-24 09:47:23 -07:00
Sarah Zakarias
f37aafd456 Add setInitialRoute on FlutterView. (#3727) 2017-06-06 10:59:41 +02:00
Ryan Macnak
1084a83f11 AOT for Fuchsia. (#3570) 2017-04-11 14:53:14 -07:00
Jason Simmons
8e7d68f823 Return an exit code from sky_shell representing what kind of error occurred (#3368)
This is intended to match the exit codes returned by the Dart command line tool
2017-01-27 09:59:08 -08:00
Jason Simmons
fdcd65eedd Exit the non-interactive sky_shell on Linux when the Dart script has completed (#3358)
The script will be finished when the microtask queue has been drained and
Dart_HasLivePorts is returning false for the main isolate
2017-01-24 15:39:30 -08:00
Adam Barth
4b8c9051e5 Remove last mojom interface (#3184)
We no longer use mojom to transport messages. We still use the Mojo EDK
to spin the event loop, however.
2016-10-28 11:46:57 -07:00
Adam Barth
9eaedb0677 Migrate ViewportMetrics away from Mojo (#3180)
Now we just pass the data directly.
2016-10-27 13:12:55 -07:00
Adam Barth
7e5d63513a Move lifecycle, navigation, and localization to platform messages (#3172)
Previously, these signals were sent over Mojo. Now we send them through
platform messages.
2016-10-25 15:51:27 -07:00
Adam Barth
82728570b7 Response messages (#3134)
Add plunbing for Host-to-Dart platform messages

We'll use the plumbing in this direction for things like key events.
2016-10-14 15:51:25 -07:00
Adam Barth
6042580f9e Rewire platform messages to work like semantics (#3118)
After this patch, platform messages now take the same path through the system
that semantics data does (on Android). Support on iOS will be in another patch.
2016-10-11 19:02:04 -07:00
Adam Barth
166f44c0f7 Remove pointer.mojom (#3102)
This patch moves the rest of the clients to use the new PointerData
transport.
2016-10-06 10:59:30 -07:00
Adam Barth
f97caf271c Expose SemanticsUpdate and SemanticsUpdateBuilder (#3098)
This patch prepares us to switch sending semantics information over mojom to
using dart:ui directly. Currently the recorded information is dropped on the
floor, but that will improve in future patches.
2016-10-05 12:22:03 -07:00
Adam Barth
30d87519b1 Stop dispatching pointer packets (#3080)
Long live pointer data packets.
2016-09-29 21:59:44 -07:00
Adam Barth
5f7b060522 Switch to manually encoded pointer data (#3073)
Rather than using mojom to encode pointer data, we now encode and decode it
manually. A future patch will remove the mojom codepath once the framework is
updated.
2016-09-28 15:50:09 -07:00
John McCutchan
1c59ddef0e Send richer service protocol respones from the Shell (#2929) 2016-08-16 12:16:41 -07:00
Adam Barth
b2058f8b3d Rename SkyView to RuntimeController (#2924)
Also, rename SkyViewClient to RuntimeDelegate. These names are more
sensible.

This patch also cleans up the RuntimeDelegate a bit, for example by
removing support for flushing real-time events, which aren't used.
2016-08-13 00:18:58 -07:00