-
Notifications
You must be signed in to change notification settings - Fork 6k
Auto detect mode to determine which rendering backend to use. #21852
Changes from all commits
8dbef3c
f5340b8
013bca2
baf3b71
baf0432
bbe1bb4
f8bb10d
85aad6f
7b34923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,40 @@ | |
// @dart = 2.10 | ||
part of engine; | ||
|
||
/// EXPERIMENTAL: Enable the Skia-based rendering backend. | ||
const bool experimentalUseSkia = | ||
/// A JavaScript entrypoint that allows developer to set rendering backend | ||
/// at runtime before launching the application. | ||
@JS('window.flutterWebRenderer') | ||
external String? get requestedRendererType; | ||
|
||
/// Whether to use CanvasKit as the rendering backend. | ||
bool get useCanvasKit => | ||
_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 commentThe 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 |
||
bool _detectRenderer() { | ||
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 commentThe 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:
Shall we prioritize running them with Canvaskit then? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( 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 commentThe 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 |
||
// html for mobile. | ||
return isDesktop; | ||
} | ||
|
||
/// Auto detect which rendering backend to use. | ||
yjbanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// Using flutter tools option "--web-render=auto" would set the value to true. | ||
/// Otherwise, it would be false. | ||
const bool _autoDetect = | ||
bool.fromEnvironment('FLUTTER_WEB_AUTO_DETECT', defaultValue: false); | ||
|
||
/// Enable the Skia-based rendering backend. | ||
yjbanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// Using flutter tools option "--web-render=canvaskit" 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 commentThe reason will be displayed to describe this comment to others. Learn more. very nit: typo for canvaskit |
||
const bool _useSkia = | ||
bool.fromEnvironment('FLUTTER_WEB_USE_SKIA', defaultValue: false); | ||
|
||
// If set to true, forces CPU-only rendering (i.e. no WebGL). | ||
|
Uh oh!
There was an error while loading. Please reload this page.