38 Commits

Author SHA1 Message Date
Chinmay Garde
b659646ffb Allow embedders to specify arbitrary data to the isolate on launch. (flutter/engine#13047)
Since this is currently only meant to be used by the embedding internally, the setter in Objective-C is only exposed via the FlutterDartProject private class extension. Unit tests have been added to the shell_unittests harness.

Fixes https://github.com/flutter/flutter/issues/37641
2019-10-10 12:31:14 -07:00
Chris Yang
cc04914ab4 Add onUnregistered callback in 'Texture' and 'FlutterTexture' (flutter/engine#12695)
Texture unregistration is finished on the GPU thread. The FlutterTexture implementation might not know when it is finished which leads to a race condition. Adding this callback so the FlutterTexture is aware of end of the unregistration process.
2019-10-08 12:45:57 -07:00
Jonah Williams
c341326d6a Add support for JIT release mode (flutter/engine#12446) 2019-09-27 11:20:54 -07:00
chunhtai
051ed653cc Add system font change listener for windows (flutter/engine#12276)
* Add windows font change logic

* update

* fix comment
2019-09-23 13:23:46 -07:00
Chinmay Garde
05d4ab774d Remove deprecated ThreadTest::GetThreadTaskRunner and use the newer CreateNewThread API. (flutter/engine#11395)
We will end up creating fewer threads in tests.
2019-08-23 12:21:46 -07:00
Shi-Hao Hong
cb707fb34a Pass Android Q insets.systemGestureInsets to Window (flutter/engine#10413)
* Pass Android Q system gesture inset information from insets.systemGestureInsets to Window.systemGestureInsets
2019-08-16 13:42:56 -04:00
Chinmay Garde
b293223a7e Add a test for creating images from bytes. (flutter/engine#10799) 2019-08-08 21:46:55 -07:00
Chinmay Garde
5a28c68b3c Fix threading and re-enable resource cache shell unit-tests. (flutter/engine#10636)
The rasterizer may only be accessed safely on the GPU task runner. The test was accessing the same on a non-engine known task runner instead (i.e the tests main task runner).

Crashes previously reproducible on all platforms with the following filters: `--gtest_filter="*ShellTest.SetResourceCacheSize*" --gtest_repeat=-1 --gtest_shuffle --gtest_random_seed=1988` at run ~400.

Fixes https://github.com/flutter/flutter/issues/37629
2019-08-05 12:47:30 -07:00
Dan Field
e9f8f66f82 skip flaky tests (flutter/engine#10633) 2019-08-05 10:22:43 -07:00
Dan Field
06e7030b0f Reland Skia Caching improvements (flutter/engine#10434) 2019-08-02 19:31:57 -07:00
gaaclarke
6acae05b3c Synchronize main thread and gpu thread for first render frame (flutter/engine#9506)
Got rid of the black frame by synchronizing the main thread with the
gpu thread to make sure a frame is rendered before presenting the
view.
2019-07-10 13:14:07 -07:00
liyuqian
8bd7715e9c Send timings of the first frame without batching (flutter/engine#9424)
For https://github.com/flutter/flutter/issues/34867

Test added:
* ReportTimingsIsCalledImmediatelyAfterTheFirstFrame
2019-06-24 12:40:38 -07:00
Jason Simmons
0e29357616 Remove build flags for dynamic patching (flutter/engine#9394) 2019-06-20 15:25:04 -07:00
liyuqian
222bbd856c Fix test name typo (flutter/engine#9362)
Had change locally but forgot to `git commit -a` before `git push`...
2019-06-18 12:38:26 -07:00
liyuqian
fe0db192d9 Report timings faster (100ms) in profile/debug (flutter/engine#9287)
This should satisfy the low-latency need of DevTools.

Test added:
* ReportTimingsIsCalledSoonerInNonReleaseMode
* ReportTimingsIsCalledLaterInReleaseMode
2019-06-11 16:51:20 -07:00
Chinmay Garde
b01f09fea6 Whitelist the —enable_mirrors flag to fix regression in existing embedder. (flutter/engine#9266) 2019-06-11 10:09:16 -07:00
Ben Konyi
00de8257d5 Remove unnecessary whitelisted flags for --dart-flags (flutter/engine#9233) 2019-06-07 14:43:43 -07:00
liyuqian
fb0ea0ef4c Add onReportTimings and FrameRasterizedCallback API (flutter/engine#8983)
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback.

Related issues:
https://github.com/flutter/flutter/issues/26154
https://github.com/flutter/flutter/issues/31444
https://github.com/flutter/flutter/issues/32447

Need review as soon as possible so we can merge this before the end of May to catch the milestone.

Tests added:
* NoNeedToReportTimingsByDefault
* NeedsReportTimingsIsSetWithCallback
* ReportTimingsIsCalled
* FrameRasterizedCallbackIsCalled
* FrameTimingSetsAndGetsProperly
* onReportTimings preserves callback zone
* FrameTiming.toString has the correct format

This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
2019-06-06 10:42:48 -07:00
Ben Konyi
ec114a767e Allow for whitelisted flags to be passed to the Dart VM (flutter/engine#9148)
* Allow for whitelisted flags to be passed to the Dart VM

Fixed part of https://github.com/flutter/flutter/issues/32176
2019-06-04 14:51:29 -07:00
Chinmay Garde
0b2269e30e Put the testing lib in the flutter namespace. (flutter/engine#8661) 2019-04-20 20:42:46 -07:00
Chinmay Garde
572b7b80fb Allow native bindings in secondary isolates. (flutter/engine#8658)
The callbacks can be wired in via the Settings object. Both runtime and shell unit-tests have been patched to test this.
2019-04-19 17:36:36 -07:00
Chinmay Garde
12410da5f7 Avoid leaking the VM in the shell unittests and assert VM state in existing tests. (flutter/engine#8628) 2019-04-18 11:32:33 -07:00
Chinmay Garde
72111314cb Remove redundant specification of the |flutter| namespace in the engine. (flutter/engine#8523) 2019-04-09 17:50:06 -07:00
Chinmay Garde
4dd267959f Rename the shell namespace to flutter. (flutter/engine#8520) 2019-04-09 17:10:46 -07:00
Chinmay Garde
1fd28a143a Rename the blink namespace to flutter. (flutter/engine#8517)
Some components in the Flutter engine were derived from the forked blink codebase. While the forked components have either been removed or rewritten, the use of the blink namespace has mostly (and inconsistently) remained. This renames the blink namesapce to flutter for consistency. There are no functional changes in this patch.
2019-04-09 12:44:42 -07:00
Chinmay Garde
7e10548a2e Wire up support for Dart fixtures in shell_unittests. (flutter/engine#8497) 2019-04-08 15:36:07 -07:00
Amir Hardon
c1c7b0a82d Merge only gpu and platform threads for platform views, fix deadlock. (flutter/engine#8045)
The reason we didn't merge just the gpu and platform threads from the get go was a deadlock in Shell:OnPlatformViewCreated and Shell:OnPlatformViewDestroyed.

The deadlock was caused by the platform thread starting a thread-hopping flow that ends ends up with the gpu thread releasing a latch that the platform thread is waiting on just after starting the cross-thread dance.
If the platform and gpu threads are the same, that last task that is posted to the gpu thread will never get executed as the gpu/platform thread is blocked on a latch.

This works around the deadlock by having a special case in the code for the scenario where the gpu and platform threads are the same.

Fixes: flutter/flutter#23974
2019-03-18 14:13:30 -07:00
Brian Osman
3dd1198f0d Remove SkColorSpaceXformCanvas, use color-managed SkSurfaces instead (flutter/engine#7548)
Behavior (visual) changes should be very minor. Things that are to be expected:
* A few things were not color managed correctly by the transform canvas (color emoji, some color filters). Those will be handled correctly with the tagged surfaces (although we're always transforming to sRGB, so nothing should change until we target a wider gamut).
* Image filtering will happen in the source color space, rather than the destination. Very minor.
* The transform canvas did caching of images in the destination color space. Now, the conversion happens at draw time. If there are performance issues, images can be pre-converted to the destination with makeColorSpace().
2019-01-22 15:34:51 -05:00
Michael Goderbauer
0def82ddb0 Unify copyright lines (flutter/engine#6757) 2018-11-07 12:24:35 -08:00
Chinmay Garde
501c2755e8 Ensure that the platform view is created and destroyed when running the shell unittests. (flutter/engine#6560) 2018-10-16 14:30:19 -07:00
Chinmay Garde
6ab2c166fd Remove all dependencies on Garnet. (flutter/engine#5869) 2018-07-26 12:49:34 -07:00
Joshua Seaton
967a473c6d [fml][fxl] Migrate AutoResetWaitableEvent to fml version. (flutter/engine#5808)
Thanks Jason for the speedy review
2018-07-20 10:12:38 -07:00
Jason Simmons
67381c0c35 Remove Blink code (flutter/engine#5218)
Fixes https://github.com/flutter/flutter/issues/12212
2018-05-10 15:57:29 -07:00
Chinmay Garde
82c5c8feda Re-land "Support multiple shells in a single process. (#4932)" (flutter/engine#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit a9dd1abd80f9c5148c74d606302171fa260365ca.
2018-04-13 13:48:15 -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