300 Commits

Author SHA1 Message Date
Chinmay Garde
e27940623b Re-land "Support multiple shells in a single process. (#4932)" (flutter/engine#4977)
This reverts commit a1befb4f3090141d738fc2b801e5454d96047121.
2018-04-11 15:41:23 -07:00
Chinmay Garde
a1befb4f30 Revert "Support multiple shells in a single process. (#4932)" (flutter/engine#4964)
This reverts commit 077d29581c35a08a076c5aeb5186855975756b55.
2018-04-10 15:28:43 -07:00
Chinmay Garde
077d29581c Support multiple shells in a single process. (flutter/engine#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
92aab4ba64 Provide a texture registry to the compositor context used for screenshots (flutter/engine#4921)
Fixes https://github.com/flutter/flutter/issues/16143
2018-04-02 15:19:04 -07:00
Alan Russian
17f59f4dd6 Add CallSuper annotation to onCreate(). (flutter/engine#4789)
This provides improved code inspection, making it easier for developers to figure out what might be going wrong if they override this and don't call super, like I just did. :-)
2018-03-30 19:03:49 -07:00
Jason Simmons
b035c5b0f6 Allow FirstFrameListeners to remove themselves from the FlutterView's list (flutter/engine#4871)
Fixes https://github.com/flutter/flutter/issues/15884
2018-03-26 15:43:38 -07:00
Stanislav Baranov
05943ceb68 Support for decimal and signed numeric keyboard (flutter/engine#4853)
* Support for decimal and signed numeric keyboard

* Comments
2018-03-26 13:14:38 -07:00
Michael Goderbauer
b716162f77 Rename isPassword to isObscured (flutter/engine#4815) 2018-03-19 15:52:16 -07:00
Jason Simmons
7c1c5b5280 Fix a missing paren (flutter/engine#4808) 2018-03-19 12:07:28 -07:00
Michael Goderbauer
e93b5198e7 Support password fields on Android (flutter/engine#4781) 2018-03-19 10:25:09 -07:00
Sarah Zakarias
1ddca173c3 Provide lookup key to access Flutter assets in the APK (flutter/engine#4785) 2018-03-16 12:59:57 +01:00
Mikkel Nygaard Ravn
d7024a868d Make standard codecs extensible (flutter/engine#4770) 2018-03-16 00:08:08 +00:00
Michael Goderbauer
05b0e970c4 Add API guard to a11y setTraversalAfter (flutter/engine#4794) 2018-03-15 10:15:56 -07:00
Brian Salomon
4064f10e01 Update external texture image code to specify GL texture format and image color type rather than GrPixelConfig (flutter/engine#4786) 2018-03-14 10:29:12 -07:00
Michael Goderbauer
3dcbbbb65e Send TYPE_VIEW_SELECTED event for changes to SemanticsFlag.isSelected (flutter/engine#4780) 2018-03-13 12:49:30 -07:00
Michael Goderbauer
ba8941f861 Add SemanticsFlag for Header (flutter/engine#4752) 2018-03-06 15:43:13 -08:00
Jason Simmons
64c99140bb Support hot and cold reload when using the APK asset provider on Android (flutter/engine#4746)
* deprecate snapshot_override, which is an obsolete predecessor of hot reload
* give the APKAssetProvider to the engine in the initial call to RunBundle
* later calls to Engine::RunBundleAndSource or Engine::SetAssetBundlePath
  will replace the APK asset provider with a DirectoryAssetBundle that uses
  the newly pushed assets
2018-03-06 10:40:19 -08:00
Michael Goderbauer
75f69f286c Use android.view.View as default for a11y nodes (flutter/engine#4737) 2018-03-05 09:51:08 -08:00
Sarah Zakarias
9f5ad5fd1e Read assets out of APK on Android (flutter/engine#4742) 2018-03-05 14:09:45 +01:00
Michael Goderbauer
4294850976 Fix traversal order for a11y scrolling (flutter/engine#4726)
Fixes https://github.com/flutter/flutter/issues/14987, but why?
2018-03-01 04:53:58 -08:00
Mikkel Nygaard Ravn
544e9d3480 Make deprecated API unavailable (flutter/engine#4722) 2018-02-28 11:14:43 +01:00
xster
5809f804f4 Add more haptic feedback varieties (flutter/engine#4699)
* Add more haptic feedback varieties

* Make the specific feedback types do nothing on <iOS 10
2018-02-27 14:55:18 -08:00
Todd Volkert
1555f6f175 Add flag to skip call to SkGraphics::Init() (flutter/engine#4694)
https://github.com/flutter/flutter/issues/14519
2018-02-20 17:42:11 -08:00
Jason Simmons
a6b520303f Use an alpha type that matches the color type in Android software rendering (flutter/engine#4681)
Fixes https://github.com/flutter/flutter/issues/14709
2018-02-15 13:00:57 -08:00
Siva
0a63f58b0c Fix strong flag setting (flutter/engine#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
Greg Spencer
8566625bfa Swap setTraversalBefore to setTraversalAfter, since setTraversalBefore is broken. (flutter/engine#4656)
It seems that setTraversalBefore doesn't work as well as setTraversalAfter for some reason, although I'm using them the same way. Some apps would lock up TalkBack when traversing if setTraversalBefore was set, but not with the equivalent setTraversalAfter.

It's not entirely clear why this is, but I'm going with this to at least get it fixed for apps we know about.

Addresses flutter/flutter#14600

See also flutter/flutter#14607
2018-02-12 10:02:25 -08:00
Michael Goderbauer
be8089ba88 Add accessibilityFocus and loseAccessibilityFocus as a11y actions (flutter/engine#4655) 2018-02-09 17:47:52 -08:00
Michael Goderbauer
27a581d213 Encode scrolling status into tree (flutter/engine#4647) 2018-02-09 15:39:58 -08:00
Jason Simmons
e75747c907 Update PlatformViewAndroid for the new definition of SemanticsNodeUpdates (flutter/engine#4636) 2018-02-05 16:11:51 -08:00
Yegor
7df584d855 iOS a11y text entry (~70% of it) (flutter/engine#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
Jason Simmons
dd0c2a273d Fix some errors in Javadoc annotations (flutter/engine#4622) 2018-01-31 13:56:32 -08:00
Greg Spencer
394c11e33f Adding semantics traversal order support (flutter/engine#4540)
This adds support for semantics traversal ordering.

It is a companion to flutter/flutter#14060, adding support for a sortIndex in the semantics data passed to the engine.

Addresses flutter/flutter#12187
2018-01-30 13:42:12 -08:00
Michael Goderbauer
90723f13fd Remove unnecessary trim (flutter/engine#4616)
... which caused trouble for a11y "select all".
2018-01-29 18:12:29 -08:00
Michael Goderbauer
0dec4daf0e Add semantic actions for copy, cut, and paste (flutter/engine#4592) 2018-01-26 12:11:38 -08:00
Michael Goderbauer
62750283ee Adds a11y action for selecting text (and moving cursor) (flutter/engine#4589)
See https://github.com/flutter/flutter/pull/14275 for framework side change.

Also includes some minor clean-ups for consistency. 

Required for https://github.com/flutter/flutter/issues/13469.
2018-01-25 15:00:29 -08:00
Michael Goderbauer
667959021d a11y: Announce changes to cursor position on Android (flutter/engine#4587) 2018-01-24 16:54:14 -08:00
Michael Goderbauer
0acff27cfc Add a11y support for selected text (flutter/engine#4584) 2018-01-24 15:08:29 -08:00
Jason Simmons
9e1e807c3e Convert other Android clipboard formats into text (flutter/engine#4578)
Fixes https://github.com/flutter/flutter/issues/14093
2018-01-22 13:55:48 -08:00
Michael Goderbauer
3c0932e7af Echo letters and words typed into TextField back (flutter/engine#4574)
Fixes https://github.com/flutter/flutter/issues/13392.
2018-01-22 11:14:12 -08:00
Ali Bitek
96ef7f6c1a Get active Context from the Registrar (flutter/engine#4523) 2018-01-20 08:46:40 +01:00
Michael Goderbauer
66fa83780d Announce when checked status changes on Android (flutter/engine#4557)
Fixes https://github.com/flutter/flutter/issues/14092
2018-01-16 23:10:17 -08:00
Michael Goderbauer
2c53613b1f Properly identify CheckBox and RadioButton on Android (flutter/engine#4547) 2018-01-12 15:27:55 -08:00
Michael Goderbauer
0258b3a3a1 Fixes crash on Android when activating Now on Tap (flutter/engine#4536) 2018-01-12 10:22:55 -08:00
Mikkel Nygaard Ravn
495f8f71f4 Deprecate support for big integers in standard message codec (flutter/engine#4528) 2018-01-09 23:58:45 +01:00
Mehmet Fidanboylu
3d611a011b Fix build break caused by https://github.com/flutter/engine/pull/4491 (flutter/engine#4524) 2018-01-07 07:51:46 -08:00
Mehmet Fidanboylu
354eeb0cf3 Add unwrap to JSONUtil (flutter/engine#4491)
We have a use for this for the internal messaging plugin. Instead of rolling our own, it made sense to add it here especially since it has the mirror functionality (wrap).
2018-01-06 14:32:00 -08:00
Jason Simmons
9ba9bfc0b2 API version check for AccessibilityNodeInfo.setEditable call (flutter/engine#4522)
Fixes https://github.com/flutter/flutter/issues/13896
2018-01-05 14:45:35 -08:00
Michael Goderbauer
ff69f13eb3 Split SemanticsFlags.isDisabled into two (flutter/engine#4517) 2018-01-04 15:15:54 -08:00
Alexander Aprelev
a4ae031706 This adds RPC call to set asset path. (flutter/engine#4323)
* This adds rpc call to simply set asset path.

This is needed when doing hot reload to pick up updated assets.

* Move asset_directory fetch for after view_id. Clean up return. Fix formatting.

* Add SetAssetBundlePath methods implementations for mac and ios

* Fix mac mm

* Fix formatting

* Merge and use nullptr
2018-01-04 09:48:01 -08:00
Sigurd Meldgaard
45bc2a7837 Apply texture transform on Android (flutter/engine#4513)
* Apply transform to textures on android
2018-01-04 16:04:30 +01:00