75 Commits

Author SHA1 Message Date
Yegor
f876bd5710
split children into two ordered lists: traversal and hit test (#5091)
* split `children` into two ordered lists: traversal and hit test

* address comments

* reduce node object byte size

* link to DebugSemanticsDumpOrder
2018-05-21 17:44:23 -07:00
Yegor
ec611470b5
replace nextNodeId/previousNodeId with hitTestPosition (#5066) 2018-04-23 16:16: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
Jason Simmons
04f3c6557c
Provide a texture registry to the compositor context used for screenshots (#4921)
Fixes https://github.com/flutter/flutter/issues/16143
2018-04-02 15:19:04 -07:00
Jason Simmons
24cf8ebd86
Support hot and cold reload when using the APK asset provider on Android (#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
Sarah Zakarias
a00f8e8bc0
Read assets out of APK on Android (#4742) 2018-03-05 14:09:45 +01:00
Greg Spencer
f5a4a93787
Swap setTraversalBefore to setTraversalAfter, since setTraversalBefore is broken. (#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
8ac6f6efa1
Encode scrolling status into tree (#4647) 2018-02-09 15:39:58 -08:00
Jason Simmons
9d93a07bde
Update PlatformViewAndroid for the new definition of SemanticsNodeUpdates (#4636) 2018-02-05 16:11:51 -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
Greg Spencer
96acd1a383
Adding semantics traversal order support (#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
4c82c566ed
a11y: Announce changes to cursor position on Android (#4587) 2018-01-24 16:54:14 -08:00
Michael Goderbauer
e4cabae56f
Add a11y support for selected text (#4584) 2018-01-24 15:08:29 -08:00
Alexander Aprelev
6bacf4522e
This adds RPC call to set asset path. (#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
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
Chris Bracken
93648ef0ed
Expose Window.viewInsets in dart:ui (#4403)
Window.viewInsets is the set of window-relative insets that describe the
area of the window that an application may want to treat as effectively
reducing the size of the content. Typically this is due to system UI
that fully obscures underlying content, such as the keyboard.

This area differs from padding in that padding is the set of insets that
describe the area of the window that may be partially (or fully)
obscured by system UI or physical intrusions into the view area (e.g.
iPhone X sensor housing, status bar, or the iPhone X home indicator
widget).

This patch does not yet enable the iOS bottom edge safe area. Once the
framework has been updated to use viewInsets for bottom-edge occlusions
(today, the keyboard), the bottom safe area will be enabled and
framework patches that depend on it, landed.
2017-11-29 16:27:15 -08:00
Chris Bracken
bc2acf7bdd
Revert "Roll Fuchsia buildtools to 85907c59e97527d79bbfdfd849d8e85c24959cc5 (#4331)" (#4340)
With the update to HEAD of the Fuchsia buildtools repo, the new clang
toolchain picked up caused link-time breakage in android x86_64
libFlutter.so builds.

Sample log:
https://build.chromium.org/p/client.flutter/builders/Linux%20Engine/builds/1974/steps/build%20android_debug_x64/logs/stdio

Sample failure:
FAILED: libflutter.so libflutter.so.TOC lib.stripped/libflutter.so
../../third_party/android_tools/ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld.gold: error: obj/flutter/shell/platform/android/libflutter/android_context_gl.o: unsupported reloc 42 against global symbol std::__ndk1::num_put<char, std::__ndk1::ostreambuf_iterator<char, std::__ndk1::char_traits<char> > >::id

This reverts commit 8ad42f0dae3cb1267c2b9ab99db80e4696ddbc3d.
2017-11-08 16:48:00 -08:00
Chris Bracken
8ad42f0dae
Roll Fuchsia buildtools to 85907c59e97527d79bbfdfd849d8e85c24959cc5 (#4331)
* Roll Fuchsia buildtools to 85907c59e97527d79bbfdfd849d8e85c24959cc5

This also updates Flutter buildroot to a6e52dbb776c45cc8c57d7143b8eb8b2e762fdfb
which disables -Wtautological-constant-compare temporarily until
https://reviews.llvm.org/D39462 lands in clang. This is in line with
Fuchsia's compiler options.

* Apply clang-format diffs

No logical changes. This applies clang-format from the latest Fuchsia
buildtools to the engine codebase.
2017-11-08 11:18:17 -08:00
Chinmay Garde
9a960f82f5 Add texture support (eg video, camera) (#4159) 2017-11-02 10:57:29 +01:00
Michael Goderbauer
b3d345e323
Android SeekBars announce their value (#4289)
* Android SeekBars announce their value

* style
2017-10-31 10:03:30 -07:00
Chinmay Garde
eabcf3aaa9
Avoid registering both the platform view and the rasterizer in the shell. (#4293)
Instead, the rasterizer can be accessed via the platform view.
2017-10-30 13:28:39 -07:00
Michael Goderbauer
91071f817b Support for accessibility label and hint (#4264)
* Support for accessibility label and hint

* review comments
2017-10-23 16:46:01 -07:00
Zachary Anderson
57f361dc6a Pass option to reuse an existing runtime controller (#4253) 2017-10-20 10:17:21 -07:00
Zachary Anderson
d3ebce9cf6 Allow a non-main entrypoint (#4238) 2017-10-18 14:19:28 -07:00
Zachary Anderson
555ccfc030 [Android] Lazily create the rasterizer and platform surface (#4207) 2017-10-12 15:38:28 -07:00
Michael Goderbauer
08961f8ec5 Format all c-like sources with clang-format (#4088)
* format

* license script adaptions

* updated licenses

* review comments
2017-09-12 15:36:20 -07:00
George Kulakowski
3aa7522c11 Rename ftl to fxl in Fuchsia specific code (#4090) 2017-09-11 15:58:48 -07:00
Ian Hickson
60bce44c9f Implement i18n features in the a11y API. (#4029) 2017-08-28 16:12:39 -07:00
xster
f187a5c219 Create platform API for first frame callback. Use for defer hiding splash screens on Android and iOS (#3956)
* Add back launch screen view until first frame on iOS

* improvements

* Move callback plumbing from ios surfaces to the gpu rasterizer. Didn’t wire java JNI yet.

* Android JNI

* Fix ios reference count and let android engine manage a view on top with launch screen

* Hook up Android activity and view

* review notes

* review notes

* Move thread switching upstream. Use weak references for callbacks.

* Some clean up
2017-08-14 15:44:52 -07:00
Jason Simmons
42f5bc5fdf Fixes related to usage of std::weak_ptr to hold PlatformViews (#3949)
* Call weak_ptr.lock(), which returns a null shared_ptr and does not throw
* IsViewInvalid was inverted
2017-08-03 10:53:17 -07:00
Carlo Bernaschina
8ba522eeae Avoid to freeze the system if hot reloading during debug (#3833) 2017-07-12 10:25:42 -07:00
Gary Qian
09de6f79da Add software as fallback if Vulkan and OpenGL fails (#3725) 2017-06-01 17:50:03 -07:00
Gary Qian
796259c089 Allow switching to the software rendering backend on Android. (#3719)
* Enable software rendering backend on android. Add "enable-software-rendering" flag.

* Fix variable naming and threading.
2017-05-31 17:27:47 -07:00
Mikkel Nygaard Ravn
68194b8df8 Distinguish between null platform message and one with zero-byte payload (#3577) 2017-04-09 00:07:28 +02:00
Jason Simmons
7356a50445 Copy platform message buffers into byte arrays passed via JNI (#3536)
The Java message object may be held by user-provided message handlers beyond
the lifetime of the raw blink::PlatformMessage and its data buffer
2017-03-28 17:15:01 -07:00
Jason Simmons
59b2fb954f Release JNI references to ByteBuffers passed from native to Java (#3535) 2017-03-28 13:58:42 -07:00
Chinmay Garde
1c07ea530f Remove uses of //base from all //flutter projects and replace them with //fml variants. (#3492) 2017-03-22 15:42:51 -07:00
Mikkel Nygaard Ravn
74de13c0bd FlutterXxxChannel concepts added to support Flutter/Android interop (#3446)
New concepts: FlutterMessageChannel (basic message send/receive superseding existing FlutterView methods), FlutterMethodChannel (method invocation and event streams), pluggable codecs for messages and method calls: unencoded binary, string, json, and 'standard' flutter binary encoding.
2017-03-01 13:54:32 +01:00
Jason Simmons
2c5f028ddd Fix a race in PlatformView construction (#3380)
The PlatformView superclass constructor was posting a task to the UI thread
that adds the view to the shell's global list.  This could result in UI thread
operations seeing PlatformView instances that are not fully constructed and do
not yet have an engine.

This was happening in https://github.com/flutter/flutter/issues/7735
2017-01-31 17:54:34 -08:00
Chinmay Garde
94306f4103 Add a Vulkan backend for Fuchsia and Android. (#3282) 2017-01-20 14:37:10 -08:00
Jason Simmons
d394e8a9bf Clear the GPU thread's EGL context only after the GPUSurfaceGL has been destroyed (#3346)
The GPUSurfaceGL holds references to Skia objects that may own GL objects.
If the GL objects are destructed on the GPU thread after the EGL context has been
dropped, then the GL delete calls will not take effect.
2017-01-18 17:19:50 -08:00
Chinmay Garde
8ae2d455be Display resident memory statistics on the performance overlay. (#3314) 2017-01-03 12:27:30 -08:00
Jason Simmons
c6e008178e Detach the EGL surface from the GPU thread and then destroy it during the FlutterView surfaceDestroyed callback (#3316)
Fixes https://github.com/flutter/flutter/issues/7147
2016-12-16 15:36:33 -08:00
Jason Simmons
74c1b2e4d7 Unblock FlutterView.getBitmap if there is no available layer tree (#3294) 2016-12-06 15:12:03 -08:00