-
Notifications
You must be signed in to change notification settings - Fork 6k
Auto detect mode to determine which rendering backend to use. #21852
Conversation
/// EXPERIMENTAL: Enable the Skia-based rendering backend. | ||
const bool experimentalUseSkia = | ||
@JS('window.flutterWebRenderer') | ||
external String? get customRenderer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "custom renderer" sounds like this is the renderer itself. I'd call this requestedRendererType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, let's leave dartdocs explaining what it's for.
Added @jonahwilliams to reviewer list to have a look at the gn changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gn changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failing test on Cirrus is fixed yesterday, we should sync to head though.
_autoDetect ? _detectRenderer() : _useSkia; | ||
|
||
/// Returns true if CanvasKit is used. | ||
/// Otherwise, returns false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nit: I believe there is one empty line between two sentences in doc comments. https://dart.dev/guides/language/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph
if (requestedRendererType != null) { | ||
return requestedRendererType! == 'canvaskit'; | ||
} | ||
// If requestedRendererType is not specified, use CanvasKit for desktop and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yjbanov @ferhatb if I'm not mistaken we are setting Canvaskit as default for desktop. I am personally not sure if we are ready for this step as testing goes:
- Majority of our unit tests are build with canvaskit.
- We have coverage in many critical areas with integration tests on Desktop browsers (text editing, font loading, keyboard, platform selection, image loading, semantics (in draft), scroll (in pr), pointer events (in pr), tree shaking, platform messages). None of them runs with Canvaskit though.
Shall we prioritize running them with Canvaskit then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. We should definitely ramp up testing in CanvasKit mode. This PR is not changing the default yet (--web-renderer=auto
will default to CanvasKit on desktop, but --web-renderer
itself defaults to html
so overall the defaults are not changing), so tests can proceed on their own schedule.
In terms of test prioritization, testing things in CanvasKit mode where the choice of renderer has known effects is a good place to start from. From your list the affected areas are: font loading, image loading. Text editing is also affected but I'm not sure our existing tests will catch the distinction, so we may need new tests. Tree shaking is affected; we use devicelab for that, so it would be best to reuse the existing tests. Other things affected by renderer choice: rendering quality, platform views. There's also performance, but our benchmarks already cover both HTML and CanvasKit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angjieli tl;dr there's no action items for this PR w.r.t. running existing tests in CanvasKit mode
/// | ||
/// Using flutter tools option "--web-render=cavanskit" would set the value to | ||
/// true. | ||
/// Using flutter tools option "--web-render=html" would set the value to false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nit: typo for canvaskit
@ferhatb @yjbanov I have an idea for increasing test coverage. When we are running framework tests with local engine, we can run them both with canvaskit and html backend. I'll do that by setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (requestedRendererType != null) { | ||
return requestedRendererType! == 'canvaskit'; | ||
} | ||
// If requestedRendererType is not specified, use CanvasKit for desktop and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angjieli tl;dr there's no action items for this PR w.r.t. running existing tests in CanvasKit mode
* 000bf4b Roll Skia from 2d2f82c00aeb to 5c7bb326a7b3 (33 revisions) (flutter/engine#22059) * ae92dbf Roll Fuchsia Linux SDK from lPMs_KwnU... to gqS_DIjN4... (flutter/engine#22057) * 92cd74e Roll Fuchsia Mac SDK from pZ9FgVZTK... to WLxBkBnZa... (flutter/engine#22055) * e51c710 Roll Dart SDK from a3d902d8598e to 9f907e198970 (2 revisions) (flutter/engine#22058) * 326b202 Reland fuchsia external view embedder will be shared with platform view (flutter/engine#22008) * a9a9a2f Roll Skia from 5c7bb326a7b3 to 65674e4c2e56 (3 revisions) (flutter/engine#22060) * 1233fe4 Revert "Revert "Explicitly make the X connection for EGL. (#21831)" (#21851)" (flutter/engine#21871) * aed8e01 Fixes Edge trigger route change announcement (flutter/engine#21975) * 6bc70e4 Reland: Migration to PlatformDispatcher and multi-window (flutter/engine#21932) * 5ca5e26 Add FlEventChannel (flutter/engine#21316) * 77b0052 Roll Skia from 65674e4c2e56 to 01b05e5b830b (3 revisions) (flutter/engine#22062) * 3d27fd5 Support loading assets from Android dynamic feature modules (flutter/engine#21504) * 742dfbe support uri intent launcher in android (flutter/engine#21275) * cde1e3f Auto detect mode to determine which rendering backend to use. (flutter/engine#21852) * 329ccf7 Roll Skia from 01b05e5b830b to 53281c712159 (1 revision) (flutter/engine#22065) * cde78c1 Add a golden scenario test for fallback font rendering on iOS take 2 (flutter/engine#22033) * 4f4599b Roll Dart SDK from 9f907e198970 to 37ccceacad41 (3 revisions) (flutter/engine#22069) * f0b10c5 [web] Prevent using DOM nodes for canvas with large number of draws (flutter/engine#22064) * a86ba57 Roll Fuchsia Mac SDK from WLxBkBnZa... to zDfaxkqlv... (flutter/engine#22073) * 645198a Roll Fuchsia Linux SDK from gqS_DIjN4... to vuKxZmSVj... (flutter/engine#22074) * 0b26570 Revert dart rolls (flutter/engine#22078)
Is there a way to check whether the HTML is being rendered only, or canvas kit is being rendered only? |
IIRC, you should be able to tell the difference by examining the compiled javascript code. @yjbanov feel free to correct me if I am wrong |
Once you have launched the application in auto mode, you can enter |
@angjieli No, my question was - how to detect which mode was set by auto setting, I don't want to explicitly force anything. |
Oh, misread the question. There is no good way to check the rendering backend at this point. IIRC, the info is not exposed to flutter application. |
@angjieli |
Yeah. Feel free to file an issue and we can fix it. |
Description
Support auto detect mode to determine which rendering backend to use.
If auto detect is enabled (set by environment variable
FLUTTER_WEB_AUTO_DETECT
), developers will be allowed to setwindow.flutterWebRenderer
to eithercanvaskit
orhtml
to select the rendering backend.If
window.flutterWebRenderer
is not set, flutter engine will usecanvaskit
for desktop device while usinghtml
for mobile device.If
window.flutterWebRenderer
is set to an invalid value (notcanvaskit
norhtml
), it will default tohtml
.If auto detect is disabled, it will check the value of environment variable
FLUTTER_WEB_USE_SKIA
. If true, usecanvaksit
. Otherwise, usehtml
.Tests
Updated some test to reflect this change.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Reviewer Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.