203 Commits

Author SHA1 Message Date
Chinmay Garde
defa8be2b1
Isolates launched by the engine instance use the settings of that instance. (#22052)
This regression was introduced in https://github.com/flutter/engine/pull/21820
for sound-null safety. The settings used to launch the VM were incorrectly used
to determine the isolate lifecycle callbacks. Since the first shell/engine in
the process also starts the VM, these objects are usually identical. However,
for subsequent engine shell/engine launches, the callbacks attached to the new
settings object would be ignored. The unit-test harness is also structured in
such a way that each test case tears down the VM before the next. So all
existing tests created a bespoke VM for the test run, and, the tests that did
create multiple isolates did not also test attaching callbacks to the settings
object.

Fixes https://github.com/flutter/engine/pull/22041
2020-10-22 02:20:50 -07:00
Chris Bracken
49c35b6177
Eliminate unnecessary linter opt-outs (#21935)
Eliminates FLUTTER_NOLINT where they can be landed without triggering
lint failures.
2020-10-16 17:24:23 -07:00
Chinmay Garde
5bd7260a1e
Enable loading snapshots with sound null safety enabled. (#21820)
Snapshots compiled with sound null-safety enabled require changes to the way in
which isolates are launched. Specifically, the `Dart_IsolateFlags::null_safety`
field needs to be known upfront. The value of this field can only be determined
once the kernel snapshot is available. This poses a problem in the engine
because the engine used to launch the isolate at shell initialization and only
need the kernel mappings later at isolate launch (when transitioning the root
isolate to the `DartIsolate::Phase::Running` phase). This patch delays launch of
the isolate on the UI task runner till a kernel mapping is available. The side
effects of this delay (callers no longer having access to the non-running
isolate handle) have been addressed in this patch. The DartIsolate API has also
been amended to hide the method that could return a non-running isolate to the
caller.  Instead, it has been replaced with a method that requires a valid
isolate configuration that returns a running root isolate. The isolate will be
launched by asking the isolate configuration for its null-safety
characteristics.

A side effect of enabling null-safety is that Dart APIs that work with legacy
types will now terminate the process if used with an isolate that has sound
null-safety enabled. These APIs may no longer be used in the engine. This
primarily affects the Dart Convertors in Tonic that convert certain C++ objects
into the Dart counterparts. All known Dart Converters have been updated to
convert C++ objects to non-nullable Dart types inferred using type traits of the
corresponding C++ object. The few spots in the engine that used the old Dart
APIs directly have been manually updated. To ensure that no usage of the legacy
APIs remain in the engine (as these would cause runtime process terminations),
the legacy APIs were prefixed with the `DART_LEGACY_API` macro and the macro
defined to `[[deprecated]]` in all engine translation units. While the engine
now primarily works with non-nullable Dart types, callers can still use
`Dart_TypeToNonNullableType` to acquire nullable types for use directly or with
Tonic. One use case that is not addressed with the Tonic Dart Convertors is the
creation of non-nullable lists of nullable types. This hasn’t come up so far in
the engine.

A minor related change is reworking tonic to define a single library target.
This allows the various tonic subsystems to depend on one another. Primarily,
this is used to make the Dart convertors use the logging utilities. This now
allows errors to be more descriptive as the presence of error handles is caught
(and logged) earlier.

Fixes https://github.com/flutter/flutter/issues/59879
2020-10-16 14:53:26 -07:00
Yuqian Li
190fd8eb51
Reland "Create root isolate asynchronously (#20142)" (#21747)
This reverts commit 5585ed99039efb3705025e1c58170cdb86af111b.

Additionally, the following _flutter.runInView deadlock is fixed.

Previously, a deadlock would occur when service protocol
_flutter.runInView is used to restart the engine wihtout tearing down
the shell: the shared mutex of the service protocol will be locked
during the restart as it's in the middle of handling a service protocol
message; if ServiceProtocol::AddHandler is also called during the
restart, the deadlock happens as AddHandler also requires such lock.

test/integration.shard/background_isolate_test.dart would fail
without this fix.
2020-10-12 12:02:30 -07:00
Jonah Williams
15c587404c
Preserve specified AssetResolvers when performing a hot restart or updating the asset directory (#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
Kaushik Iska
149df4318d
Reland multiple display support for embedder API (#21464) 2020-09-28 12:35:34 -07:00
Kaushik Iska
8d165faca1
Revert multiple display support for embedder API (#21456)
This reverts commits
- 67fdd7ededcbb161a857cc187619ae115c8c8e7f.
- 854943d5c8670a241524b71945b2c8ca77246556.

See: https://github.com/flutter/flutter/issues/66829
2020-09-28 09:46:46 -07:00
Kaushik Iska
67fdd7eded
Embedder API Support for display settings (#21355)
Embedders can now notify shell during startup about the various displays and their corresponding settings.
Adds a notion of Display update type which can later include chages to displays during runtime such as addition / removal / reconfiguration of displays.

We also remove the responsibility of providing the refresh rate from `vsync_waiter` to `DisplayManager`.
Rewires existing platform implementations of the said API to use `Shell::OnDisplayUpdate` to notify the display manager of the startup configuration.

DisplayManager is also thread-safe to account for rasterizer and UI thread accesses.
2020-09-25 11:04:10 -07:00
Dan Field
634e499bcc
Use hint freed specifically for image disposal (#20754)
* Use hint freed specifically for image disposal
2020-09-02 13:41:58 -07:00
Yuqian Li
5585ed9903
Revert "Create root isolate asynchronously (#20142)" (#20937)
This reverts commit 95f2b72728ee7e51800f1784e458e45dac675b3a.
2020-09-01 22:05:53 -07:00
chenjianguang
95f2b72728
Create root isolate asynchronously (#20142)
## Description
As the related issue refer, the application may be doing too much work on its main thread even in a simple hello_world demo.
That is because the creation of `Engine` on the ui thread takes a noticeable time, and it is blocking the platform thread in order to run `Shell::Setup` synchronously.
The cost of `Engine`'s constructor is mainly about the creating of root isolate. Actually, there used to be another time-consuming process, the default font manager setup, which was resolved by https://github.com/flutter/engine/pull/18225. 
Similar to https://github.com/flutter/engine/pull/18225, this pr move the creation of root isolate out from creating `Engine`. After this action, the main thread blocking is quite an acceptable slice.

## Related Issues
https://github.com/flutter/flutter/issues/40563 could be resolved by this pr.
2020-09-01 13:31:00 -07:00
Dan Field
4a88d5e109
Revert hint_freed (#20746)
This caused over-aggressive GCs, which vastly increased CPU usage benchmarks.

* Revert "fix build (#20644)"

This reverts commit b59793ee20be29463fac7a79635bf20253f04107.

* Revert "Hint freed (#19842)"

This reverts commit 3930ac1b25820baee3c67d921a0b009606cb3dae.
2020-08-25 11:55:40 -07:00
Dan Field
3930ac1b25
Hint freed (#19842)
* Hint the VM when a layer or picture goes out of scope
2020-08-19 14:04:31 -07:00
David Worsham
5a2bf6aa4c
Reland: "fuchsia: Remove dead code / break dependencies" (#20532)
Reland #19396 with a fix for improper scale that was affecting internal tests

Tested: Ran all unittests, ran internal tests, and ran workstation on Fuchsia
BUG: 53062, 53063
2020-08-14 20:41:18 -07:00
gaaclarke
2ea8396860
Added unit tests to the engine. (#20216) 2020-08-07 15:55:58 -07:00
Zachary Anderson
47c1c61a92
Revert "fuchsia: Remove dead code / break dependencies (#19396)" (#20302)
This reverts commit 12a37478de2cc9aff7f8fc72bc3a47f5f02e083c.
2020-08-06 12:06:06 -07:00
David Worsham
12a37478de
fuchsia: Remove dead code / break dependencies (#19396)
The fuchsia code around metrics and sizing was just sending this
information through a side-channel, when the engine already had the
information available. So, delete all of it to make future CLs simpler.

Additionally, the SceneUpdateContext has many unneccesary dependencies
re: metrics and PaintTasks. Break those to make future CLs simpler.

Tested: Ran all unittests and ran workstation on Fuchsia
BUG: 53062, 53063
2020-08-03 22:09:26 -07:00
Mehmet Fidanboylu
908fe012d9
Fix navigation message relay. (#20193) 2020-08-02 14:28:27 -07:00
Greg Spencer
98cfd1db78
Move platform specific information to PlatformConfiguration class (#19652) 2020-07-31 17:21:02 -07:00
gaaclarke
49a40faba1
Enabled linting on engine.cc (#19981) 2020-07-29 13:08:23 -07:00
gaaclarke
21efd7325e
Made the linter print out more information in its output and fixed bugs (#19895) 2020-07-22 15:38:09 -07:00
Gary Qian
637a8e7cd0
Revert method channel platform resolved locale (#19136) 2020-06-19 17:40:22 -07:00
Gary Qian
3a96741247
Platform resolved locale and Android localization refactor (#18645) 2020-06-16 04:29:50 -07:00
chenjianguang
89cf074d37
Setup default font manager after engine created, to improve startup performance (#18225) 2020-05-28 17:53:04 -07:00
Gary Qian
8dc91229b4
PlatformResolvedLocale localization message channel (#17755) 2020-04-21 15:34:44 -07:00
chunhtai
7a27e75c67
Add shell api to set default for windows data (#14002) 2020-01-08 19:36:10 -08:00
Kaushik Iska
f2dbeb8aa7
Reland Wire up Opacity on Fuchsia (#14559)
This reverts commit 6ea69a0d4339dd153899bb6c299689f1dd43329d.

On top of the revert, it reverted a commit in the PR:
https://github.com/flutter/engine/pull/14024

This reverts commit ea67e5b0b930ebf552bc7dbd678a35ee6a129c39.
2019-12-18 16:05:38 -08:00
Kaushik Iska
6ea69a0d43
Revert "Wire up Opacity on Fuchsia, round 2 (#14024)" (#14543)
This reverts commit d117ac979c28363a0a6b02d4a54945212a88b6f9.
2019-12-18 10:29:47 -08:00
David Worsham
d117ac979c
Wire up Opacity on Fuchsia, round 2 (#14024)
* Remove erroneous ChildView opacity

* Wire frame metrics through contexts

* Maintain layer stack inside of SceneBuilder

* Remove EnsureSingleChild

* Centralize system-composite and elevation logic

* Wire up OpacityLayer to Scenic
2019-12-04 19:29:31 -08:00
gaaclarke
89e395853c
Refactor to passing functions by const ref (#13975)
Moved our code to passing functions by const ref
2019-11-22 12:20:02 -08:00
chunhtai
1f1e2ba58e
reland add lifecycle enum (#13767)
This reverts commit 8ebb318401344793daa10c3bec97c34891cf7cc8.
2019-11-13 11:26:25 -08:00
chunhtai
8ebb318401
Revert "Issues/39832 reland (#13642)" (#13720)
This reverts commit 1bfb928e071674a21779cee94908fbcae1c2e657.
2019-11-06 11:41:36 -08:00
chunhtai
1bfb928e07
Issues/39832 reland (#13642)
* Reland "Added new lifecycle enum (#11913)"
2019-11-05 14:52:16 -08:00
chunhtai
fe0838e948
Revert "Added new lifecycle enum (#11913)" (#13632)
This reverts commit 02a479007420b05df8e075978ecdd15442ea520f.
2019-11-04 13:40:20 -08:00
chunhtai
02a4790074
Added new lifecycle enum (#11913) 2019-11-04 12:33:41 -08:00
gaaclarke
1eb15c12fb
Revert 78a8ca0f62b04fa49030ecdd2d91726c0639401f (#13467)
Put `Picture.toImage` back on the GPU thread.  Left the unit tests intact.
2019-10-31 16:57:52 -07:00
gaaclarke
25fcf531fa
Made restarting the Engine remember the last entrypoint that was used. (#13289) 2019-10-22 14:01:52 -07:00
Ryan Macnak
f6900001eb
Roll Dart to 6a65ea9cad4b014f88d2f1be1b321db493725a1c. (#13294)
Remove dead shared snapshot arguments to Dart_CreateIsolateGroup.

6a65ea9cad4b [vm] Remove shared snapshot and reused instructions features.
db8370e36147 [gardening] Fix frontend-server dartdevc windows test.
4601bd7bffea Modified supertype check error message to be more descriptive.
0449905e2de6 [CFE] Add a serialization-and-unserialization step to strong test
c8b903c2f94f Update CHANGELOG.md
2a12a13d9684 [Test] Skips emit_aot_size_info_flag_test on crossword.
b26127fe01a5 [cfe] Add reachability test skeleton
2019-10-22 13:14:20 -07:00
gaaclarke
0d43469b40
Revert "Made restarting the Engine remember the last entrypoint that was used. (#13264)" (#13287)
This reverts commit 9dd585c463c35950a79471fab80023cfa9ce9c26.
2019-10-22 10:03:10 -07:00
gaaclarke
9dd585c463
Made restarting the Engine remember the last entrypoint that was used. (#13264) 2019-10-22 08:10:57 -07:00
Jason Simmons
4ecfa62735
Hold a reference to the Skia unref queue in UIDartState (#13239)
Obtaining the SkiaUnrefQueue through the IOManager is unsafe because
UIDartState has a weak pointer to the IOManager that can not be dereferenced
on the UI thread.
2019-10-21 14:15:03 -07:00
Chinmay Garde
c92613bc49
Re-land "Custom compositor layers must take into account the device pixel ratio."
This reverts commit 6c2381da6070f9e96825841e77e9ffeb376d6aa9 and applies iOS fixes.
2019-10-17 14:07:51 -07:00
Chinmay Garde
6c2381da60
Revert "Custom compositor layers must take into account the device pixel ratio. (#13193)" (#13211)
This reverts commit e53d10c3456ccac1bffabc78a16fd6ce680d0074.
2019-10-17 12:59:27 -07:00
Chinmay Garde
e53d10c345
Custom compositor layers must take into account the device pixel ratio. (#13193)
The contents rendered into the backing stores are already correctly scaled.
The initial implementation assumed this also held true for the metrics obtained
via embedded view parameters.

Fixes b/142699417
2019-10-17 12:04:13 -07:00
Chinmay Garde
86e3ebb748
Allow embedders to specify arbitrary data to the isolate on launch. (#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
liyuqian
9675ca2f6b
Reland "Smooth out iOS irregular input events delivery (#12280)" (#12385)
This reverts commit c2879cae2ee3707ad07af1118bf4862dc1d82bb7.

Additionally, we fix https://github.com/flutter/flutter/issues/40863 by adding a secondary VSYNC callback.

Unit tests are updated to provide VSYNC mocking and check the fix of https://github.com/flutter/flutter/issues/40863.

The root cause of having https://github.com/flutter/flutter/issues/40863 is the false assumption that each input event must trigger a new frame. That was true in the framework PR https://github.com/flutter/flutter/pull/36616 because the input events there are all scrolling move events. When the PR was ported to the engine, we can no longer distinguish different types of events, and tap events may no longer trigger a new frame.

Therefore, this PR directly hooks into the `VsyncWaiter` and uses its (newly added) secondary callback to dispatch the pending input event.
2019-09-30 11:25:50 -07:00
liyuqian
7c3dcee2e9
Revert "[fuchsia] Wire up OpacityLayer to Scenic (#11322)" (#12610)
This reverts commit fcc4ab32301396986dd5103d6d444bff35fe0f63.

Fixes https://github.com/flutter/flutter/issues/41394 and other
related correctness issues.

TBR: @arbreng @jason-simmons @mehmetf
2019-09-27 16:50:43 -07:00
David Worsham
fcc4ab3230
[fuchsia] Wire up OpacityLayer to Scenic (#11322)
On Fuchsia, add a build flag for compositing OpacityLayers using the system
compositor vs Skia, which exposes a fastpath for opacity via Scenic.
This will only work under certain circumstances, in particular nested
OpacityLayers will not render correctly!

On Fuchsia, add a build flag for compositing PhysicalShapeLayers using
the system compositor vs Skia. Set to off by default, which restores
performant shadows on Fuchsia.

Remove the opacity exposed from ChildView, as that was added mistakenly.

Finally, we centralize the logic for switching between the
system-composited and in-process-composited paths inside of
ContainerLayer. We also centralize the logic for computing elevation
there. This allows the removal of many OS_FUCHSIA-specific code-paths.

Test: Ran workstation on Fuchsia; benchmarked before and after
Bug: 23711
Bug: 24163

* Fix broken tests
2019-09-25 12:48:42 -04:00
liyuqian
c2879cae2e
Revert "Reland "Smooth out iOS irregular input events delivery (#11817)" (#12280)" (#12364)
This reverts commit aac33d1bced7a9d15e1feb19f73eef6da16470f0.

Reason: flutter/flutter#40863

TBR: chinmaygarde, iskakaushik
2019-09-19 19:39:36 -07:00
liyuqian
aac33d1bce
Reland "Smooth out iOS irregular input events delivery (#11817)" (#12280)
Additionally, we now use the engine directly as a delegate instead of storing potentially dead runtime_controller.

Unit tests have been updated to include an engine restart check which would fail before the fix.

This fixes https://github.com/flutter/flutter/issues/40303
2019-09-16 10:42:44 -07:00