601 Commits

Author SHA1 Message Date
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
Jonah Williams
8a6e64a8ef
Revert "Do not pause rendering when android activity loses focus (#4848)" (#4985)
This reverts commit c83d1ef12df0cf8b11a6dda044f812f8cc6c16ef.
2018-04-12 11:20:24 -07:00
Jonah Williams
c83d1ef12d
Do not pause rendering when android activity loses focus (#4848)
* do not pause rendering when android view loses focus
2018-04-12 11:00:31 -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
Chris Bracken
4883131507
Set FlutterTexture copyPixelBuffer return nullable (#4934)
This is to support Swift users, where nil is allowed for CVPixelBufferRef.
2018-04-04 13:53:49 -07:00
Jason Simmons
deea53519b
Set the asset bundle path when initializing the shell in the embedder API (#4925)
This is required so that Dart initialization can find the platform kernel
assets when running in Dart 2 mode
2018-04-03 09:47:57 -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
Alan Russian
924b111cea
Add CallSuper annotation to onCreate(). (#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
Ryan Macnak
dd6f46c485 Make flutter_test on Mac exit on error like Linux and Windows. (#4873) 2018-03-26 20:51:19 -07:00
Jason Simmons
5e8557330a
Allow FirstFrameListeners to remove themselves from the FlutterView's list (#4871)
Fixes https://github.com/flutter/flutter/issues/15884
2018-03-26 15:43:38 -07:00
Stanislav Baranov
7fa08b3ba9
Support for decimal and signed numeric keyboard (#4853)
* Support for decimal and signed numeric keyboard

* Comments
2018-03-26 13:14:38 -07:00
Brian Salomon
3e877d371a Remove declaration for undefined GPUSurfaceGL::SelectPixelConfig (#4857) 2018-03-23 12:38:58 -04:00
Jason Simmons
01be4c6017
Fix GPUSurfaceGL includes on Linux (#4849) 2018-03-22 11:40:29 -07:00
Chris Bracken
2ec5a67d53
Fix supported color type check on iOS simulators (#4846)
Since OS_MACOSX and OS_IOS are both enabled for simulator builds, ensure
we're using constants conistent with our #includes.
2018-03-21 19:31:24 -07:00
Chris Bracken
9b837652b1
Fix GPUSurfaceGL includes on macOS (#4844)
macOS doesn't include GLES support.
2018-03-21 16:45:41 -07:00
Chris Bracken
604f51e675
Handle Apple-specific GLES headers (#4843)
In 60befc2cdec54818ce738fd07236624dc1b287a2, includes were added for
GLES. On macOS/iOS, these headers are named slightly differently.
2018-03-21 16:16:04 -07:00
Brian Salomon
60befc2cde VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig (#4814)
* VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig

* fix 565

* fix gpu_surface_gl changes
2018-03-21 14:13:05 -07:00
Sarah Zakarias
2114a88b5e
Provide asset lookup key on ios (#4817) 2018-03-21 11:36:49 +01:00
Michael Goderbauer
c3ab0c9143
Rename isPassword to isObscured (#4815) 2018-03-19 15:52:16 -07:00
Jason Simmons
a9b5e1bdac
Fix a missing paren (#4808) 2018-03-19 12:07:28 -07:00
Michael Goderbauer
cc6b45014b
Support password fields on Android (#4781) 2018-03-19 10:25:09 -07:00
Chris Bracken
cd9c438ce3
Eliminate iOS depth/stencil buffer code (#4802)
As of ba67d0fe718299050bf0195295aba3415c417b91, depth/stencil buffer
attachments are never used. This patch eliminates generation and binding
of depth/stencil render buffers since these code paths are no longer hit.
2018-03-16 16:47:06 -07:00
Chris Bracken
c9fe39978c
Cache render buffer extents when no depth/stencil buffer (#4801)
Previously iOS render buffer storage width and height were not cached if
not using a depth/stencil buffer. This adds a similar check for
colorBuffer to avoid reallocating render buffer storage.
2018-03-16 15:40:31 -07:00
Sarah Zakarias
2c5a1bf507
Provide lookup key to access Flutter assets in the APK (#4785) 2018-03-16 12:59:57 +01:00
Mikkel Nygaard Ravn
9671f63459
Make standard codecs extensible (#4770) 2018-03-16 00:08:08 +00:00
Michael Goderbauer
7d9e42ac61
Add API guard to a11y setTraversalAfter (#4794) 2018-03-15 10:15:56 -07:00
Brian Salomon
7eb06c1b1d Update external texture image code to specify GL texture format and image color type rather than GrPixelConfig (#4786) 2018-03-14 10:29:12 -07:00
Michael Goderbauer
d042b3e830
Send TYPE_VIEW_SELECTED event for changes to SemanticsFlag.isSelected (#4780) 2018-03-13 12:49:30 -07:00
Jason Simmons
e61bb9ac3a
Enable libtxt as the default text renderer (#4779) 2018-03-13 11:35:40 -07:00
Michael Goderbauer
e44cd55fc4
Manually given hint,value,label,trait has precedence for TextFields on iOS (#4777) 2018-03-12 17:56:08 -07:00
Chinmay Garde
ba67d0fe71
Don’t specify a stencil buffer attachment for the onscreen FBO. (#4778) 2018-03-12 17:37:11 -07:00
Jason Simmons
f0c0da5ca5
Revert "Enable libtxt as the default text renderer" (#4774)
This reverts commit d9fcdfb676fcec50b0bdf6e57731b511fa922b46.
2018-03-12 11:40:19 -07:00
Jason Simmons
d9fcdfb676
Enable libtxt as the default text renderer (#4773) 2018-03-12 11:15:21 -07:00
Adam Barth
14c940e277
Switch from fxl::Mutex to std::mutex (#4764)
We're going to remove fxl::Mutex soon.
2018-03-09 11:19:23 -08:00
Chinmay Garde
5bffdefbbf
Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (#4761) 2018-03-08 17:23:01 -08:00
Jason Simmons
1d0da77995
Revert "Enable libtxt as the default text renderer (#4751)" (#4758)
This reverts commit 1b7325ca6825a1305d5521a5c0abe6fb32688dea.
2018-03-08 16:17:02 -08:00
Michael Goderbauer
7f7634fa17
Add SemanticsFlag for Header (#4752) 2018-03-06 15:43:13 -08:00
Jason Simmons
1b7325ca68
Enable libtxt as the default text renderer (#4751) 2018-03-06 13:12:39 -08: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
Michael Goderbauer
16fe8f6b98
Use android.view.View as default for a11y nodes (#4737) 2018-03-05 09:51:08 -08:00
Sarah Zakarias
a00f8e8bc0
Read assets out of APK on Android (#4742) 2018-03-05 14:09:45 +01:00
Chris Bracken
269bab73b6
Add nil check for country code and language code (#4732)
NSLocale objectForKey: may return nil for NSLocaleLanguageCode and
NSLocateCountryCode in certain cases.

This adds a defensive nil check for such cases.
2018-03-01 13:46:22 -08:00
Michael Goderbauer
a4b1fccdaa
Fix traversal order for a11y scrolling (#4726)
Fixes https://github.com/flutter/flutter/issues/14987, but why?
2018-03-01 04:53:58 -08:00
Sarah Zakarias
4d7065af2d
remove unavailabe API from FlutterDartProject.mm (#4724) 2018-02-28 14:04:14 +01:00
Sarah Zakarias
42bbef1d7e
Remove unavailable API in FlutterDartProject.h (#4723) 2018-02-28 13:37:00 +01:00
Mikkel Nygaard Ravn
3656278894
Make deprecated API unavailable (#4722) 2018-02-28 11:14:43 +01:00