-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Preserve canvaskit variant during tests. #43868
[web] Preserve canvaskit variant during tests. #43868
Conversation
…zation (flutter#43854)" This reverts commit 6c224e8.
This way we cannot accidentally remove/unset properties when writing tests.
mdebbar
left a comment
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.
Thanks for making this improvement!
My only serious concern is with the behavior of debugOverrideJsConfiguration(null).
| <title>${htmlEscape.convert(test)} Test</title> | ||
| <meta name="assetBase" content="/"> | ||
| <script> | ||
| window._flutter_canvaskit_variant_for_test_only = "$canvasKitVariant"; |
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.
I still think this is valuable as it protects us from accidental messing with the configuration. I don't feel too strongly about it though, so I'll leave it up to your judgement.
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.
I am just trying to avoid adding more special global stuff to the configuration of the flutter app. In this case, it feels extra redundant because we're already passing it through the engine configuration call a few lines below.
| /// Sets the given configuration as the current one. | ||
| /// Overrides [configuration] with new values coming from `newConfig`. | ||
| /// | ||
| /// If `newConfig` is null, the override is removed. |
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.
It isn't clear to me what "removing the override" means. Do we go back to the hardcoded default values? Do we go back to what was specified in window.flutterConfiguration?
By looking at the code, it looks like the former is the case. If that's correct, then I think we should change it. Going back to the hardcoded defaults means we are resetting the configuration for all subsequent tests, and we lose the configurations that were passed by test_platform.dart.
In other similar situations, we keep two copies: the original value (in this case, it's whatever came from window.flutterConfiguration) and the override value. When debugOverrideXXX = null; then we just set the override value to null but we keep the original value. An example here:
engine/lib/web_ui/lib/src/engine/browser_detection.dart
Lines 54 to 56 in 3342e09
| BrowserEngine get browserEngine { | |
| return debugBrowserEngineOverride ?? _browserEngine; | |
| } |
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 my understanding is correct, something like this captures the failure if test_platform.dart sets a canvasKitVariant that's different from the default:
final CanvasKitVariant originalValue = configuration.canvasKitVariant;
debugOverrideJsConfiguration(
<String, Object?>{
'canvasKitVariant': 'auto',
}.jsify() as JsFlutterConfiguration?
);
expect(configuration.canvasKitVariant, CanvasKitVariant.auto);
debugOverrideJsConfiguration(null);
expect(configuration.canvasKitVariant, originalValue);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.
When we remove the override in configuration, we should be going back to the default configuration values set in JS:
engine/lib/web_ui/lib/src/engine/configuration.dart
Lines 53 to 56 in cd8cfa0
| /// The Web Engine configuration for the current application. | |
| FlutterConfiguration get configuration => | |
| _configuration ??= FlutterConfiguration.legacy(_jsConfiguration); | |
| FlutterConfiguration? _configuration; |
The test that you proposed above should indeed pass, let's add it to the configuration tests!
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.
I added the test to the same test file that tests that the canvaskit variant is set by default (but that it can also be overridden).
I've also expanded the documentation of the method a little bit, but I'm not sure if it's doing it any favors for clarity or making it worse 😮💨, let me know!
mdebbar
left a comment
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.
| /// Subsequent calls to this method don't *add* more to an already overridden | ||
| /// configuration; this method always starts from an original `_jsConfiguration`, | ||
| /// and adds `newConfig` to it. |
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.
Oh interesting. Good call on clarifying this!
…131314) flutter/engine@43f727e...df12fff 2023-07-26 [email protected] [web] Preserve canvaskit variant during tests. (flutter/engine#43868) 2023-07-26 [email protected] Roll Skia from 28773cec6e8d to 826e38ba8db3 (5 revisions) (flutter/engine#44031) 2023-07-26 [email protected] Roll Fuchsia Mac SDK from 0StTjIqUxGkc3nOWT... to d6O9t74z-k2svOmvz... (flutter/engine#44030) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from 0StTjIqUxGkc to d6O9t74z-k2s If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#131314) flutter/engine@43f727e...df12fff 2023-07-26 [email protected] [web] Preserve canvaskit variant during tests. (flutter/engine#43868) 2023-07-26 [email protected] Roll Skia from 28773cec6e8d to 826e38ba8db3 (5 revisions) (flutter/engine#44031) 2023-07-26 [email protected] Roll Fuchsia Mac SDK from 0StTjIqUxGkc3nOWT... to d6O9t74z-k2svOmvz... (flutter/engine#44030) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from 0StTjIqUxGkc to d6O9t74z-k2s If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#131314) flutter/engine@43f727e...df12fff 2023-07-26 [email protected] [web] Preserve canvaskit variant during tests. (flutter/engine#43868) 2023-07-26 [email protected] Roll Skia from 28773cec6e8d to 826e38ba8db3 (5 revisions) (flutter/engine#44031) 2023-07-26 [email protected] Roll Fuchsia Mac SDK from 0StTjIqUxGkc3nOWT... to d6O9t74z-k2svOmvz... (flutter/engine#44030) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from 0StTjIqUxGkc to d6O9t74z-k2s If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
A ~~simpler~~ very similar version of flutter#43854 * Makes it harder for users to accidentally remove default configuration values, while still allowing them to do so if needed (configuration is now overridden with a subset of values, rather than passing a full configuration object). * Moves `merge` from the configuration object and into the override method. * Removes a test-only configuration option: * `window._flutter_canvaskit_variant_for_test_only` [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style

A
simplervery similar version of #43854mergefrom the configuration object and into the override method.window._flutter_canvaskit_variant_for_test_onlyPre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.