504 Commits

Author SHA1 Message Date
Jonah Williams
03e3c8bc39 Do not pause rendering when android activity loses focus (flutter/engine#4848)
* do not pause rendering when android view loses focus
2018-04-12 11:00:31 -07:00
Vyacheslav Egorov
a9dd1abd80 Revert "Re-land "Support multiple shells in a single process. (#4932)" (#4977)" (flutter/engine#4981)
This reverts commit e27940623b550f50fece0740ea3d6e9cb259fdae.
2018-04-12 18:28:55 +02:00
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
Chris Bracken
1a82cb0edc Set FlutterTexture copyPixelBuffer return nullable (flutter/engine#4934)
This is to support Swift users, where nil is allowed for CVPixelBufferRef.
2018-04-04 13:53:49 -07:00
Jason Simmons
0134aeca41 Set the asset bundle path when initializing the shell in the embedder API (flutter/engine#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
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
Ryan Macnak
485d4b795d Make flutter_test on Mac exit on error like Linux and Windows. (flutter/engine#4873) 2018-03-26 20:51:19 -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
Sarah Zakarias
18fe5d7dec Provide asset lookup key on ios (flutter/engine#4817) 2018-03-21 11:36:49 +01: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
Chris Bracken
507f0c79aa Eliminate iOS depth/stencil buffer code (flutter/engine#4802)
As of d5fdb1a189f3bf5973ec3e667c92cb906816946b, 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
c4d964e1f5 Cache render buffer extents when no depth/stencil buffer (flutter/engine#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
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
858b66885c Manually given hint,value,label,trait has precedence for TextFields on iOS (flutter/engine#4777) 2018-03-12 17:56:08 -07:00
Chinmay Garde
e0799300ff Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (flutter/engine#4761) 2018-03-08 17:23:01 -08: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
Chris Bracken
37165bd6cc Add nil check for country code and language code (flutter/engine#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
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
Sarah Zakarias
01ee444738 remove unavailabe API from FlutterDartProject.mm (flutter/engine#4724) 2018-02-28 14:04:14 +01:00
Sarah Zakarias
e0fdc00ee7 Remove unavailable API in FlutterDartProject.h (flutter/engine#4723) 2018-02-28 13:37:00 +01: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
Chris Bracken
a5e4e34bbc Re-enable Dart_TimelineGetMicros on init on macOS (flutter/engine#4712)
Previously, a call to Dart_TimelineGetMicros() before a call to
Dart_Initialize() resulted in a crash. This was fixed in
dart-lang/sdk@7434bcad57.

Related:
* flutter/flutter#4006: SkyShell.app on Mac crashes on startup
* dart-lang/sdk#26486:  [dart_tools_api.h] Dart_TimelineGetMicros crashes on Mac if called before Dart_Initialize
2018-02-24 10:21:40 -08:00
Yegor
81545c43df fix naming of static function intToComparisonResult (flutter/engine#4685) 2018-02-22 11:24:51 -07: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
Mikkel Nygaard Ravn
5de8c90177 Place LICENSE as sibling of podspec (flutter/engine#4691) 2018-02-19 16:33:30 +01:00
Yegor
d9a1fb11b5 iOS a11y: Implement strong down weak up reference management (flutter/engine#4602)
* fix iOS crash in a11y mode when used too fast

* clang-format
2018-02-15 16:33:05 -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
Brian Osman
6d0f9bb2b3 On iOS, render to an offscreen surface to avoid renderbuffer slowdown (flutter/engine#4680)
* On iOS, render to an offscreen surface to avoid renderbuffer slowdown

Fixes https://github.com/flutter/flutter/issues/14565

* null out old offscreen surface
2018-02-14 16:17:35 -05:00
Chris Bracken
a6f0be9844 Fix unguarded availability warnings for iOS (flutter/engine#4664)
Place all iOS code that relies on APIs introduced in iOS versions later
than our base SDK version (iOS 8) behind @available checks. This allows
us to enable the -Wunguarded-availability compiler flag for iOS builds
in the buildroot repo.
2018-02-13 11:49:43 -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
Alexander Aprelev
3e577d6940 Remove xibs (flutter/engine#4648) 2018-02-07 16:20:06 -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