59 Commits

Author SHA1 Message Date
Jonah Williams
43c54b4b98 Update setAssetDirectory service extension to fail if provided path is invalid (flutter/engine#35178) 2022-08-05 15:47:04 +00:00
Chris Bracken
09285aac02 Use empty in place of size checks vs 0 (flutter/engine#33151) 2022-05-06 13:09:04 -07:00
freiling
a8cea746b9 [fuchsia][shader warmup] Avoid recursively iterating over assets directory when loading skp's due to high cost of openat() on pkgfs (flutter/engine#25006)
* [fuchsia][shader warmup] Fixed SkpWarmupTest

This test regressed due to https://github.com/flutter/engine/pull/23488
and this regression was silent due to https://github.com/flutter/flutter/issues/78277

Credit to @gnoliyil for actually putting together the fix.

* [fuchsia][shader warmup] Avoid recursively iterating over assets directory when loading skp's due to high cost of openat() on pkgfs
2021-04-01 23:23:52 -07:00
Chris Bracken
9b4a0264d5 Correct typos throughout the engine/embedder (flutter/engine#25346)
Used the the `misspell` tool available at
https://github.com/client9/misspell, then applied hand-corrections. It's
possible we could adopt this as a presubmit, but there are still enough
false positives that it may not be worth the effort.
2021-04-01 11:08:19 -07:00
Gary Qian
2bfbb4197c AssetResolver updating in AssetManager for Dynamic features (flutter/engine#23130) 2020-12-23 17:39:55 -08:00
freiling
4903a92b2b SKP based shader warmup (flutter/engine#20643) 2020-11-04 23:19:02 -08:00
Jonah Williams
127f3af9e0 Preserve specified AssetResolvers when performing a hot restart or updating the asset directory (flutter/engine#21611)
Follow up from #21436 . That PR works for all embeddings except for Android, which creates a special JNI AssetResolver. Since the shell cannot recreate this resolver, update the logic to preserve existing resolvers instead.
2020-10-08 09:22:01 -07:00
Chinmay Garde
8f5f888826 Use the standard [[nodiscard]] attribute instead of an FML macro. (flutter/engine#17100) 2020-03-11 13:36:01 -07:00
Chinmay Garde
426c48aaac Remove all uses of the redundant flutter_root variable. (flutter/engine#16311)
This was only necessary when the Engine had to build in multiple buildroots
where the sources where checked out at different paths relative to the
buildroot. This is no longer the case and there are already cases GN rules
have been written that mix and match variable usage with the direct
specification of the path to the Flutter sources relative to the sole buildroot.
2020-01-31 21:49:48 -08:00
Jason Simmons
42bc3c04a9 Return an empty mapping for an empty file asset (flutter/engine#10815)
Fixes https://github.com/flutter/flutter/issues/36574
2019-08-13 10:02:59 -07:00
Jason Simmons
e4a2320fdd Simplify loading of app bundles on Android (flutter/engine#9360)
* Remove deprecated runBundle APIs
* Remove code related to dynamic patching (including support for multiple
  bundle paths)
* Change FlutterRunArugments.bundlePath to be the Android AssetManager path
  where the app's assets are located
2019-06-25 14:17:50 -07:00
Zachary Anderson
35107c4dca Revert tracing changes (flutter/engine#9296)
* Revert "[fuchsia] Fix alignment of Fuchsia/non-Fuchsia tracing (#9289)"

This reverts commit e7d406fe36790b1a8161d4687a6a4a144ba44254.

* Revert "Align fuchsia and non-fuchsia tracing (#9199)"

This reverts commit 1ccb372e5f8ceaaf90f5b43b42df617d7f18d955.
2019-06-12 10:25:49 -07:00
Dan Field
1ccb372e5f Align fuchsia and non-fuchsia tracing (flutter/engine#9199) 2019-06-05 15:14:27 -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
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
Stanislav Baranov
733d65dd7b Support loading flutter assets from dynamic patch (flutter/engine#7308)
This replicates similar logic found in ApkAssetProvider that locates assets by their short name in a sudbirectory inside of an archive file, instead of only at the root of archive.
2018-12-28 10:34:47 -08:00
Michael Goderbauer
082336e7c2 Fix code smells reported by chrome's clang plugin (flutter/engine#6833) 2018-11-12 19:59:29 -08:00
Michael Goderbauer
0def82ddb0 Unify copyright lines (flutter/engine#6757) 2018-11-07 12:24:35 -08:00
Ryan Macnak
67ce8a7cde Report asset names in loading trace events. (flutter/engine#6713) 2018-11-01 12:29:29 -07:00
Chinmay Garde
ddd0b8887a Handle Windows headers defining ERROR to 0 in log levels. (flutter/engine#6677) 2018-10-26 16:47:14 -07:00
Chinmay Garde
68887916e2 Realize kernel asset mappings on a worker thread if one is available. (flutter/engine#6648) 2018-10-24 11:33:46 -07:00
Chinmay Garde
74c44fa72a Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278)
Also teaches FML to create files and directories.
2018-09-26 14:54:09 -07:00
Chinmay Garde
c1c309ae2d Make //flutter/synchronization Garnet free. (flutter/engine#5865) 2018-07-25 14:30:41 -07:00
Chinmay Garde
62289623fc Remove //flutter/glue and use FML directly. (flutter/engine#5862) 2018-07-25 13:20:48 -07:00
Jason Simmons
cdf3d96360 Remove the dependency on the Garnet zip library (flutter/engine#5770) 2018-07-16 15:02:57 -07:00
Ryan Macnak
e8df7055bc Replace AssetResolver GetAsBuffer with GetAsMapping. (flutter/engine#5546)
Toward no-copy loading of kernel.
2018-06-19 14:24:19 -07:00
Stanislav Baranov
5afc3daf35 Support running bundles from zip file. (flutter/engine#5473)
Support running bundles from zip file.
2018-06-07 15:09:23 -07:00
Stanislav Baranov
9054d0f274 Restore archive support removed in #5305. Codepush bundles use zip. (flutter/engine#5441) 2018-06-01 12:46:27 -07:00
Chinmay Garde
1718f9b935 Break the FXL from flutter/assets. (flutter/engine#5316) 2018-05-18 17:04:36 -07:00
Chinmay Garde
00d7bf3b5b Remove support for reading FLX archives from engine. (flutter/engine#5305)
The embedders have moved on already. This also removes a //garnet dependency on zlib wrappers.
2018-05-18 11:56:37 -07:00
Chinmay Garde
61d20bfe48 Only make ERROR and FATAL log levels visible by default. (flutter/engine#5022)
Adds the --verbose-logging flag to enable logging at all other severities.
2018-04-16 21:34:11 -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
Sarah Zakarias
9f5ad5fd1e Read assets out of APK on Android (flutter/engine#4742) 2018-03-05 14:09:45 +01:00
Adam Barth
db4e089e22 Reduce logspam in DirectoryAssetBundle (flutter/engine#4690)
It's not an error to request an asset that doesn't exist. In fact, we
request kernel_blob.bin unconditionally at startup, which doesn't
typically exist.
2018-02-19 08:38:45 -08:00
Sarah Zakarias
a50c855b12 Run Fuchsia apps without flx (flutter/engine#4550) 2018-01-15 11:09:01 +01:00
Sarah Zakarias
2ac17ebc40 Revert "Run Fuchsia apps without flx" (flutter/engine#4545)
* Revert "include portable_unistd.h in directory_asset_bundle (#4542)"

This reverts commit a41471bdd6692ec78c04d3bf6b0fc4601e622876.

* Revert "Run Fuchsia apps without flx (#4538)"

This reverts commit 9bf76142c1b68565347a6c7a8d6eab56cba5256b.
2018-01-12 15:55:47 +01:00
Sarah Zakarias
57330c3bff Revert "include portable_unistd.h in directory_asset_bundle (#4542)" (flutter/engine#4544)
This reverts commit a41471bdd6692ec78c04d3bf6b0fc4601e622876.
2018-01-12 15:53:02 +01:00
Sarah Zakarias
a41471bdd6 include portable_unistd.h in directory_asset_bundle (flutter/engine#4542) 2018-01-12 15:31:56 +01:00
Sarah Zakarias
9bf76142c1 Run Fuchsia apps without flx (flutter/engine#4538) 2018-01-12 13:31:54 +01:00
Sarah Zakarias
d8a79eacf9 Select fonts from asset directory instead of FLX (flutter/engine#4464) 2017-12-18 09:01:56 +01:00
Sarah Zakarias
5b8c89eaf0 Handle Flutter assets outside FLX (flutter/engine#4343) 2017-12-13 10:55:24 +01:00
Ben Konyi
31f0a6055c Changes to assets/ build/ flow/ runtime/ and shell/ to allow for compilation on Windows (flutter/engine#4407)
Made changes to assets/ build/ flow/ runtime/ and shell/ to allow for
compilation on Windows.
2017-11-30 19:47:20 -05:00
P.Y. Laligand
235f07742a Allow the project to be mapped to a location other than //flutter. (flutter/engine#4203)
This is for Fuchsia where we would like it to be located at //third_party/flutter.
2017-10-13 17:00:58 -07:00
Michael Goderbauer
ac24af87f0 Format all c-like sources with clang-format (flutter/engine#4088)
* format

* license script adaptions

* updated licenses

* review comments
2017-09-12 15:36:20 -07:00
George Kulakowski
b2b9a646ca Fix remaining ftl->fxl conversions (flutter/engine#4091)
* Fix remaining ftl->fxl conversions

The previous scripting pass at this did not account for objective c file endings

* Update tonic DEPS reference to the post-fxl version
2017-09-11 16:31:18 -07:00
George Kulakowski
fa539e618e Rename ftl to fxl in Fuchsia specific code (flutter/engine#4090) 2017-09-11 15:58:48 -07:00