Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Make updating window metrics multi-view #43366

Merged
merged 25 commits into from
Jul 8, 2023

Conversation

dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Jun 30, 2023

This PR adds multi-view support to various methods that updates the window metrics by adding a view_id parameter.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -330,7 +332,8 @@ TEST_F(EngineTest, SpawnResetsViewportMetrics) {
const double kViewHeight = 1024;
old_viewport_metrics.physical_width = kViewWidth;
old_viewport_metrics.physical_height = kViewHeight;
mock_runtime_controller->SetViewportMetrics(old_viewport_metrics);
mock_runtime_controller->SetViewportMetrics(kDefaultViewId,
old_viewport_metrics);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses PlatformData.viewport_metrics to check the metrics, which appears to be a single-view assumption. Should we update PlatformData as part of this change? I'm fine with punting this until later, but I'd consider adding a TODO with a tracking issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I added a TODO at RuntimeController::FlushRuntimeStateToIsolate. I can add one more here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't think an extra one is needed here. PlatformData.viewport_metrics is definitely something we need to change in the future, which will for sure affect this test. The TODO I mentioned above should be enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put a TODO on PlatformData::viewport_metrics as well? Skipping the TODO here sounds good though 👍

@@ -978,9 +979,9 @@ void Shell::OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) {
});

task_runners_.GetUITaskRunner()->PostTask(
[engine = engine_->GetWeakPtr(), metrics]() {
[engine = engine_->GetWeakPtr(), metrics, view_id]() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider swapping captures to match argument order:

Suggested change
[engine = engine_->GetWeakPtr(), metrics, view_id]() {
[engine = engine_->GetWeakPtr(), view_id, metrics]() {

I don't feel strongly about this.

@@ -413,9 +413,10 @@ class PlatformConfiguration final {
///
/// @param[in] window_id The id of the window to find and return.
///
/// @return a pointer to the Window.
/// @return a pointer to the Window. Nullptr if the ID is not registered
/// yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember what our plan is for Canvas::drawShadow? It uses the implicit view's device pixel ratio:

SkScalar dpr = static_cast<float>(UIDartState::Current()
->platform_configuration()
->get_window(0)
->viewport_metrics()
.device_pixel_ratio);

If the implicit view is disabled, this will crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I totally forgot. I'll open an issue to discuss this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkwingsmt
Copy link
Contributor Author

@loic-sharma I think I've addressed all of your comments. Would you like to take another look?

/// rendering viewport in texels as well as edge insets if
/// present.
/// @brief Updates the viewport metrics for a view. The viewport metrics
/// detail the size of the rendering viewport in texels as well as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is texels correct here? It looks like that's a thing but it seems like pixels would make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was written by @/chinmaygarde. Maybe you can ask him for details? (Since I'm not really familiar with texels either...)

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work!

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 8, 2023

auto label is removed for flutter/engine, pr: 43366, due to - The status or check suite Linux linux_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2023
@auto-submit auto-submit bot merged commit 9006633 into flutter:main Jul 8, 2023
@dkwingsmt dkwingsmt deleted the multiview-window-metrics branch July 8, 2023 05:54
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 8, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 8, 2023
…130195)

flutter/engine@4ca6191...9006633

2023-07-08 [email protected] Make updating window metrics multi-view (flutter/engine#43366)
2023-07-08 [email protected] Rename default views to implicit views (flutter/engine#43364)

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
kjlubick pushed a commit to kjlubick/engine that referenced this pull request Jul 14, 2023
This PR adds multi-view support to various methods that updates the window metrics by adding a `view_id` parameter.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-android platform-fuchsia platform-ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants