723 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
Clement Skau
e78e405e6a
Enable lazy-async-stacks by-default in all modes (Take 4) (#21802) 2020-10-20 10:31:15 +02: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
Chris Bracken
c449c8ee50
Eliminate FLUTTER_NOLINT where possible (#21904)
This removes most of the remaining FLUTTER_NOLINT comments and opts
these files back into linter enforcement.

I've filed https://github.com/flutter/flutter/issues/68273 to require
that all FLUTTER_NOLINT comments be followed by a GitHub issue URL
describing the problem to be fixed.
2020-10-16 12:44:49 -07:00
Jenn Magder
4494a83742
Add flag to not publish the observatory port over mDNS (#21883) 2020-10-15 14:53:20 -07:00
Jenn Magder
40c226e253
Revert "Add flag to not publish the observatory port over mDNS (#21632)" (#21882)
This reverts commit dc848f154b9c5534262e5b8d3f0360a1beafdeb5.
2020-10-15 12:32:24 -07:00
Jenn Magder
dc848f154b
Add flag to not publish the observatory port over mDNS (#21632)
* Add flag to not publish the observatory port over mDNS

* Review edits

* Format
2020-10-15 10:48:50 -07:00
Yuqian Li
c2938d06b1
Revert "Migration to PlatformDispatcher and multi-window #20496" (#21792)
* Revert "Fix documentation build for window changes. (#21780)"

This reverts commit 931a04683d6eb49fc92059b2384ac5b1618d5422.

* Revert "Migration to PlatformDispatcher and multi-window (#20496)"

This reverts commit 85b0031f73544e448354047dc6a236c0b0808252.
2020-10-12 19:26:41 -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
Greg Spencer
85b0031f73
Migration to PlatformDispatcher and multi-window (#20496)
This is a PR for converting the dart:ui code in the engine to use a multi-window API. The goal here is to convert from the window singleton to an API that has the concept of multiple windows. Also, I'm matching up the new PlatformDispatcher class to talk directly to the PlatformConfiguration class in the engine. I'm not attempting to actually enable creating multiple windows here, just migrate to an API that has a concept of multiple windows. The multi-window API in this PR currently only ever creates one window.

The design doc for this change is here.

The major changes in this PR:

Move the platfom-specific attributes out of Window, and into the new PlatformDispatcher class that holds all of the platform state, so that the platform code need only update the configuration on this class.
Create FlutterView, FlutterWindow, and SingletonFlutterWindow classes to separate out the concepts of a view (of which there may be multiple in a window), a window (of which there may be multiple on a screen, and they host views), and a window where there is only ever expected to be one (this hosts the entire API of the former Window class, and will eventually be the type of the window singleton).
Next step after this PR lands:

Remove the Window class entirely (it is replaced by SingletonFlutterWindow). Some minor changes in the Framework are needed to switch to using SingletonFlutterWindow directly first.

The Window class still exists in this PR, but will be removed as soon as the framework is converted to point to the SingletonFlutterWindow class instead. They share the same API, just have different names (Window is currently a subclass of SingletonFlutterWindow). The intention is that the Window name will be freed up to use as a widget class name in the framework for managing windows. The singleton called window will remain, and keep the same API it has now.
2020-10-09 16:29:16 -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
Pieter van Loon
85ed656722
Enabled metal on ios simulator (#17881) 2020-10-07 17:47:03 -07:00
George Wright
ea420db5fd
Use the gpu config for shell_unittests to declare SHELL_ENABLE_{GL,VULKAN} (#21603) 2020-10-06 12:47:02 -07:00
Yuqian Li
e59e893d4e
Do not remove directories in purge (#21478)
Otherwise, the persistent cache may hold invalid directories and make
subsequent store fail.

The newly added unit tests would fail without the fix.
2020-10-05 20:05:00 -07:00
Jonah Williams
3c0da65c0c
Allow hot reload without syncing all asset files to devFS (#21436)
Always add the asset resolver from the configuration settings directory when restarting or recreating the asset manager
2020-10-02 14:09:07 -07:00
Kaushik Iska
149df4318d
Reland multiple display support for embedder API (#21464) 2020-09-28 12:35:34 -07:00
Jason Simmons
e3bb787fb8
Do not pass invalid platform view rendering surfaces to the rasterizer (#21259) 2020-09-28 11:57:01 -07:00
George Wright
ab2b0111f7
Enable embedder_unittests on Fuchsia (#21418) 2020-09-28 11:12:02 -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
aa8d5d4b9b
Avoid sending a 0 DPR to framework (#21389)
* Avoid sending a 0 DPR to framework

* check width and height as well
2020-09-25 10:35:57 -07:00
Matej Knopp
5c9dddc376
Discard wrong size layer tree instead of rendering it (#21179) 2020-09-18 12:37:02 -07:00
George Wright
e25596c6a5
Disable ShellTest.SkipAndSubmitFrame for flakes (#21254) 2020-09-17 16:20:52 -07:00
Martin Kustermann
c0b75ffd19
Add --enable-isolate-groups to allowed flags in switches.cc (#21149)
This will allow customers to try out the lightweight isolate support in the Dart VM in AOT mode.

To be future proof, we also add the negative flags to the allow list, thereby allowing the Dart VM to
change the default in the future, while still allowing customers to opt out.

Issue b/158554251
2020-09-17 14:33:51 -07:00
Chris Bracken
08dabe9601
Clean up C++ includes (#21127)
Cleans up header order/grouping for consistency: associated header, C/C++ system/standard library headers, library headers, platform-specific #includes.

Adds <cstring> where strlen, memcpy are being used: there are a bunch of places we use them transitively.

Applies linter-required cleanups. Disables linter on one file due to included RapidJson header. See https://github.com/flutter/flutter/issues/65676

This patch does not cover flutter/shell/platform/darwin. There's a separate, slightly more intensive cleanup for those in progress.
2020-09-11 21:18:35 -07:00
Chris Bracken
16b900b63e
Prefer C++ standard headers to their C counterpart (#21091)
We currently use a mix of C standard includes (e.g. limits.h) and their
C++ variants (e.g. climits). This migrates to a consistent style for all
cases where the C++ variants are acceptable, but leaves the C
equivalents in place where they are required, such as in the embedder
API and other headers that may be used from C.
2020-09-11 17:10:00 -07:00
Emmanuel Garcia
85a7afa913
Add a new raster status kSkipAndRetry frame (#21059) 2020-09-11 16:29:11 -07:00
Jason Simmons
22982407d4
Check for a valid SkSL cache directory before calling VisitFiles (#21118)
The directory may be invalid when running shell_unittests because
some tests call SetCacheDirectoryPath and then delete the directory.
Later tests that try to use that cache base path will be unable to
open the directory.
2020-09-11 16:23:25 -07:00
Chris Bracken
36f7f3ca82
Copyright header hygiene improvements (#21089)
Add copyright headers in a few files where they were missing.

Trim trailing blank comment line where present, for consistency with
other engine code.

Use the standard libtxt copyright header in one file where it differed
(extra (C) and comma compared to other files in libtxt).

This also amends tools/const_finder/test/const_finder_test.dart to look
for a const an additional four lines down to account for the copyright
header added to the test fixture.
2020-09-11 08:55:37 -07:00
David Worsham
a52397e05f
fuchsia: Compile disabled RasterThreadMerger code (#20984) 2020-09-09 18:40:01 -07:00
chenjianguang
5271340b88
Fix usage of WeakPtr valid check (#20106) 2020-09-09 15:34:24 -07:00
Yuqian Li
00978035cd
Open a fresh dir during LoadSkSLs (#21050)
Fixes https://github.com/flutter/flutter/issues/65258

The following devicelab tests should pass after this patch:

- flutter_gallery_sksl_warmup__transition_perf_e2e_ios32
- flutter_gallery_sksl_warmup_ios32__transition_perf
2020-09-09 15:33:33 -07:00
Zachary Anderson
f7c7b41f0a
Revert "Enable lazy-async-stacks by-default in all modes (Take 3) (#20895)" (#21043)
This reverts commit 575a51948d81756c778352b40f639fa557325fd7.
2020-09-09 09:25:17 -07:00
Clement Skau
575a51948d
Enable lazy-async-stacks by-default in all modes (Take 3) (#20895)
Lazy async stacks were already enabled by-default in AOT mode in [0] - which made the
gen_snapshot invocations use "--lazy-async-stacks --no-causal-async-stacks".

This change does the same with the engine defaults, which makes this be enabled
by-default in JIT mode as well.

See go/dart-10x-faster-async for more information.

This is a re-land: A fix for what we believe to have caused the last revert has landed upstream in Dart in dart-lang/sdk@0004589

[0] flutter/flutter@3478232
2020-09-07 10:55:48 +02:00
Emmanuel Garcia
367c6dbd12
Don't use GetTaskQueueId() in rasterizer as it breaks Fuchsia (#20983) 2020-09-03 16:40:01 -07:00
Jim Graham
841401db8c
restore FML_DCHECK removed due to a code reviewing error (#20953) 2020-09-03 14:46:28 -07:00
0xZero
ac8b9c4c52
Member variables should appear before the |WeakPtrFactory|. (#20899) 2020-09-03 14:34:01 -07:00
Jason Simmons
d368b8763a
Log the results when ShellTest.Screenshot fails (#20932)
This test has been flaky on LUCI recently.

See https://github.com/flutter/flutter/issues/65026
2020-09-03 14:13:55 -07:00
Emmanuel Garcia
3f05b521b9
Always set the callback during Rasterizer setup (#20976) 2020-09-03 10:48:46 -07:00
Emmanuel Garcia
efb339f300
Only clear GL context after changing the thread configuration (#20965) 2020-09-02 22:10:02 -07:00
Emmanuel Garcia
61e057aa59
Clear GL context before Gr context (#20957) 2020-09-02 15:08:16 -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
Emmanuel Garcia
615e668014
Clear the GL context only after submitting the frame (#20931)
* Clear the GL context only after submitting the frame
* Fix Screenshot test
2020-09-02 08:46:11 -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
Jason Simmons
1bd9b8e85b
Reset Shell::weak_factory_gpu_ on the raster thread (#20869) 2020-08-31 16:03:02 -07:00
Emmanuel Garcia
c4c4f341b8
Wait for first frame before checking layer tree (#20910) 2020-08-31 15:03:31 -07:00
Emmanuel Garcia
5e54c707e8
Reland: Enable hybrid composition by default on Android (#20722) (#20864)
This reverts commit 4de62c7c2659607acdc75ab8c1ccd305a3c6f9d1.
2020-08-31 12:17:11 -07:00
Emmanuel Garcia
52f62f14f7
Fix race condition (#20905) 2020-08-31 10:11:41 -07:00