Prioritize reusing existing virtual monitors when setting video layout. [chromium/src : main]

0 views
Skip to first unread message

Jamie Walch (Gerrit)

unread,
Feb 17, 2026, 5:30:26 PM (4 days ago) Feb 17
to AyeAye, chromotin...@chromium.org

Jamie Walch added 1 comment

File remoting/host/linux/gnome_desktop_resizer.cc
Line 279, Patchset 1 (Latest): auto it = available_screen_ids.begin();
Jamie Walch . unresolved

I'm not sure if it's worth trying to pick the id that corresponds to the monitor with greatest overlap with the new one or not. The 99% use-case for this is restoring a 2-display layout that was saved by the display layout dialog immediately after adding a display, and therefore has no id for that display. For this use-case the extra code would be overkill.

If we wanted to pick the "best" display, is there sufficient information in `preferred_monitors_config_`?

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
Gerrit-Change-Number: 7585714
Gerrit-PatchSet: 1
Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Feb 2026 22:30:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Feb 17, 2026, 6:18:51 PM (4 days ago) Feb 17
to Jamie Walch, AyeAye, chromotin...@chromium.org
Attention needed from Jamie Walch

Yuwei Huang added 2 comments

File remoting/host/linux/gnome_desktop_resizer.cc
Line 279, Patchset 1 (Latest): auto it = available_screen_ids.begin();
Jamie Walch . unresolved

I'm not sure if it's worth trying to pick the id that corresponds to the monitor with greatest overlap with the new one or not. The 99% use-case for this is restoring a 2-display layout that was saved by the display layout dialog immediately after adding a display, and therefore has no id for that display. For this use-case the extra code would be overkill.

If we wanted to pick the "best" display, is there sufficient information in `preferred_monitors_config_`?

Yuwei Huang

Do you mean with greatest overlap in desktop geometry?

Am I correct that the CUJ you try to fix here is that when the user connected, they didn't immediately restore the previous display layout (which should just work since it is requesting a new display), but they later added a new display and decided to restore the previous display layout? It sounds like this might be easier to achieve on the client side (i.e. the client finds the best matching existing display for a non-existent display in the stored layout)? But in any case, it doesn't seem like we gain much by matching the display with the greatest overlap.

If we wanted to pick the "best" display, is there sufficient information in preferred_monitors_config_?

It probably has. It has the expected sizes and positions of all the displays that are managed by CRD.

Line 307, Patchset 1 (Latest): // SetResolutionAndPosition() calls below know whether they should be
Yuwei Huang . unresolved

`streams_being_removed_` is now set after the `SetResolutionAndPosition` calls at line 294. Based on the comment on [do_after_stream_removal_](https://source.chromium.org/chromium/chromium/src/+/main:remoting/host/linux/gnome_desktop_resizer.h;l=167;drc=9b82a5f081c62c4d20cdb0dd996c5504097f1dbf), if you first change the resolution of stream A then immediate remove stream B, then GNOME has a chance to crash. Is this no longer reproducing in GNOME 49?

Maybe a safer approach is to queue up the `SetResolutionAndPosition` calls (as a vector of callbacks?) then call them after this block.

Open in Gerrit

Related details

Attention is currently required from:
  • Jamie Walch
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
Gerrit-Change-Number: 7585714
Gerrit-PatchSet: 1
Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
Gerrit-Attention: Jamie Walch <jamie...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Feb 2026 23:18:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Jamie Walch <jamie...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Jamie Walch (Gerrit)

unread,
Feb 17, 2026, 7:39:19 PM (4 days ago) Feb 17
to Yuwei Huang, AyeAye, chromotin...@chromium.org
Attention needed from Yuwei Huang

Jamie Walch added 2 comments

File remoting/host/linux/gnome_desktop_resizer.cc
Line 279, Patchset 1: auto it = available_screen_ids.begin();
Jamie Walch . unresolved

I'm not sure if it's worth trying to pick the id that corresponds to the monitor with greatest overlap with the new one or not. The 99% use-case for this is restoring a 2-display layout that was saved by the display layout dialog immediately after adding a display, and therefore has no id for that display. For this use-case the extra code would be overkill.

If we wanted to pick the "best" display, is there sufficient information in `preferred_monitors_config_`?

Yuwei Huang

Do you mean with greatest overlap in desktop geometry?

Am I correct that the CUJ you try to fix here is that when the user connected, they didn't immediately restore the previous display layout (which should just work since it is requesting a new display), but they later added a new display and decided to restore the previous display layout? It sounds like this might be easier to achieve on the client side (i.e. the client finds the best matching existing display for a non-existent display in the stored layout)? But in any case, it doesn't seem like we gain much by matching the display with the greatest overlap.

If we wanted to pick the "best" display, is there sufficient information in preferred_monitors_config_?

It probably has. It has the expected sizes and positions of all the displays that are managed by CRD.

Jamie Walch

Do you mean with greatest overlap in desktop geometry?

Am I correct that the CUJ you try to fix here is that when the user connected, they didn't immediately restore the previous display layout (which should just work since it is requesting a new display), but they later added a new display and decided to restore the previous display layout?

When saving a layout proto on the client, each display may come from the host, or it might be a "pending" display that only exists in the layout config dialog. The difference is basically whether or not the user added a display before checking the "restore layout" option. Both cases have a problem where the current state of the host might not match what it was when the setting was saved:

  • If the display came from the host, it might not exist any more. In that case, https://chromium-review.googlesource.com/c/chromium/src/+/7557558 takes the view that although we can't guarantee the display id in the request, we can at least create a display with the right size and position.
  • If the display was pending when the proto was saved, but now exists, then without this CL we will delete the previous display and create a new one. It will have the right size and position, but the window manger might not restore move windows back onto it.

It sounds like this might be easier to achieve on the client side (i.e. the client finds the best matching existing display for a non-existent display in the stored layout)?

We don't want to wait for the host to send its initial layout before replacing it with the saved layout. It can be fixed on the client, but only by setting a "layout pending" flag, and saving the next layout that the host sends (which will have the correct display ids). That seems more complex and error-prone, which is why I preferred this host-side approach.

Line 307, Patchset 1: // SetResolutionAndPosition() calls below know whether they should be
Yuwei Huang . resolved

`streams_being_removed_` is now set after the `SetResolutionAndPosition` calls at line 294. Based on the comment on [do_after_stream_removal_](https://source.chromium.org/chromium/chromium/src/+/main:remoting/host/linux/gnome_desktop_resizer.h;l=167;drc=9b82a5f081c62c4d20cdb0dd996c5504097f1dbf), if you first change the resolution of stream A then immediate remove stream B, then GNOME has a chance to crash. Is this no longer reproducing in GNOME 49?

Maybe a safer approach is to queue up the `SetResolutionAndPosition` calls (as a vector of callbacks?) then call them after this block.

Jamie Walch

Callbacks seemed a hit heavyweight, so I refactored it a bit to preprocess the displays instead so that things should still happen in the same order as without this CL.

Open in Gerrit

Related details

Attention is currently required from:
  • Yuwei Huang
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
Gerrit-Change-Number: 7585714
Gerrit-PatchSet: 5
Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
Gerrit-Attention: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Wed, 18 Feb 2026 00:39:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
Comment-In-Reply-To: Jamie Walch <jamie...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Feb 17, 2026, 8:02:14 PM (4 days ago) Feb 17
to Jamie Walch, AyeAye, chromotin...@chromium.org
Attention needed from Jamie Walch

Yuwei Huang voted and added 1 comment

Votes added by Yuwei Huang

Code-Review+1

1 comment

File remoting/host/linux/gnome_desktop_resizer.cc
Line 279, Patchset 1: auto it = available_screen_ids.begin();
Jamie Walch . resolved

I'm not sure if it's worth trying to pick the id that corresponds to the monitor with greatest overlap with the new one or not. The 99% use-case for this is restoring a 2-display layout that was saved by the display layout dialog immediately after adding a display, and therefore has no id for that display. For this use-case the extra code would be overkill.

If we wanted to pick the "best" display, is there sufficient information in `preferred_monitors_config_`?

Yuwei Huang

Do you mean with greatest overlap in desktop geometry?

Am I correct that the CUJ you try to fix here is that when the user connected, they didn't immediately restore the previous display layout (which should just work since it is requesting a new display), but they later added a new display and decided to restore the previous display layout? It sounds like this might be easier to achieve on the client side (i.e. the client finds the best matching existing display for a non-existent display in the stored layout)? But in any case, it doesn't seem like we gain much by matching the display with the greatest overlap.

If we wanted to pick the "best" display, is there sufficient information in preferred_monitors_config_?

It probably has. It has the expected sizes and positions of all the displays that are managed by CRD.

Jamie Walch

Do you mean with greatest overlap in desktop geometry?

Am I correct that the CUJ you try to fix here is that when the user connected, they didn't immediately restore the previous display layout (which should just work since it is requesting a new display), but they later added a new display and decided to restore the previous display layout?

When saving a layout proto on the client, each display may come from the host, or it might be a "pending" display that only exists in the layout config dialog. The difference is basically whether or not the user added a display before checking the "restore layout" option. Both cases have a problem where the current state of the host might not match what it was when the setting was saved:

  • If the display came from the host, it might not exist any more. In that case, https://chromium-review.googlesource.com/c/chromium/src/+/7557558 takes the view that although we can't guarantee the display id in the request, we can at least create a display with the right size and position.
  • If the display was pending when the proto was saved, but now exists, then without this CL we will delete the previous display and create a new one. It will have the right size and position, but the window manger might not restore move windows back onto it.

It sounds like this might be easier to achieve on the client side (i.e. the client finds the best matching existing display for a non-existent display in the stored layout)?

We don't want to wait for the host to send its initial layout before replacing it with the saved layout. It can be fixed on the client, but only by setting a "layout pending" flag, and saving the next layout that the host sends (which will have the correct display ids). That seems more complex and error-prone, which is why I preferred this host-side approach.

Yuwei Huang

We don't want to wait for the host to send its initial layout before replacing it with the saved layout.

Ah, I think this is what I was missing. This LGTM now. Thanks for explaining!

Open in Gerrit

Related details

Attention is currently required from:
  • Jamie Walch
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
    Gerrit-Change-Number: 7585714
    Gerrit-PatchSet: 5
    Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Attention: Jamie Walch <jamie...@chromium.org>
    Gerrit-Comment-Date: Wed, 18 Feb 2026 01:02:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Jamie Walch (Gerrit)

    unread,
    Feb 18, 2026, 12:54:58 PM (4 days ago) Feb 18
    to Yuwei Huang, AyeAye, chromotin...@chromium.org

    Jamie Walch voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
    Gerrit-Change-Number: 7585714
    Gerrit-PatchSet: 5
    Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
    Gerrit-Reviewer: Jamie Walch <jamie...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Comment-Date: Wed, 18 Feb 2026 17:54:49 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Chromium LUCI CQ (Gerrit)

    unread,
    Feb 18, 2026, 1:34:08 PM (4 days ago) Feb 18
    to Jamie Walch, Yuwei Huang, AyeAye, chromotin...@chromium.org

    Chromium LUCI CQ submitted the change

    Change information

    Commit message:
    Prioritize reusing existing virtual monitors when setting video layout.

    When a new video layout is received, this change modifies the logic to
    avoid removing displays and adding others, preferring to reuse existing
    displays instead. It can be thought of as a counterpart to
    whereas that CL handled the case where the client attempts to restore
    the geometry of a display that no longer exists, this one handles the
    case where the layout saved by the client includes "new display"
    requests that have subsequently been actioned. In particular, when
    adding new displays using client UI, they don't have an id until the
    host creates them.
    Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
    Reviewed-by: Yuwei Huang <yuw...@chromium.org>
    Commit-Queue: Jamie Walch <jamie...@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1586546}
    Files:
    • M remoting/host/linux/gnome_desktop_resizer.cc
    • M remoting/host/linux/gnome_desktop_resizer_unittest.cc
    Change size: M
    Delta: 2 files changed, 98 insertions(+), 31 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Yuwei Huang
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5e3591cf0924b0c8a88dbb53a19f70f528bf7833
    Gerrit-Change-Number: 7585714
    Gerrit-PatchSet: 6
    Gerrit-Owner: Jamie Walch <jamie...@chromium.org>
    Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages