Add better error support for CopyFromSurface method [chromium/src : main]

0 views
Skip to first unread message

David Bokan (Gerrit)

unread,
Dec 4, 2025, 2:56:34 PM (12 days ago) Dec 4
to Tianyang Xu, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
Attention needed from Tianyang Xu

David Bokan added 5 comments

File chrome/browser/ai/ai_data_keyed_service.cc
Line 528, Patchset 3 (Latest): const base::expected<viz::CopyOutputBitmapWithMetadata, std::string>&
David Bokan . unresolved

We should add a `using CopyFromSurfaceResult = base:expected...` so that we can use `CopyFromSurfaceResult` instead of this everywhere. It's clearer and if we ever want to update e.g. string -> ErrorCode it would be a simpler change

Line 538, Patchset 3 (Latest): result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap)),
David Bokan . unresolved

Can you file a bug and leave TODOs in places like this...callers need to be updated to handle the returned error explicitly rather than (hopefully) checking for an empty bitmap

File chrome/browser/media/webrtc/tab_desktop_media_list.cc
Line 299, Patchset 3 (Latest): if (!result.has_value()) {
// CopyFromSurface failed..
return;
}
David Bokan . unresolved

This changes behavior...if we don't have a result we need to provide an empty one / empty bitmap below.

File chrome/browser/support_tool/screenshot_data_collector.cc
Line 297, Patchset 3 (Latest): if (!result.has_value()) {
SupportToolError error = {
SupportToolErrorCode::kDataCollectorError,
David Bokan . unresolved

ditto here and for other cases - aim to leave existing behavior unchanged

File content/browser/renderer_host/render_widget_host_impl.cc
Line 3567, Patchset 3 (Latest): const SkBitmap& bitmap =
result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
David Bokan . unresolved

This is a better pattern to ensure we don't change existing behavior...as noted above, with a TODO to explain that error reporting was added this code was written.

Open in Gerrit

Related details

Attention is currently required from:
  • Tianyang Xu
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
Gerrit-Change-Number: 7229082
Gerrit-PatchSet: 3
Gerrit-Owner: Tianyang Xu <xtls...@google.com>
Gerrit-CC: Andrew Rayskiy <green...@google.com>
Gerrit-CC: David Bokan <bo...@chromium.org>
Gerrit-CC: James Su <su...@chromium.org>
Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-CC: Simon Hangl <sim...@google.com>
Gerrit-Attention: Tianyang Xu <xtls...@google.com>
Gerrit-Comment-Date: Thu, 04 Dec 2025 19:56:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Tianyang Xu (Gerrit)

unread,
Dec 5, 2025, 4:40:16 PM (11 days ago) Dec 5
to David Bokan, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
Attention needed from David Bokan

Tianyang Xu added 5 comments

File chrome/browser/ai/ai_data_keyed_service.cc
Line 528, Patchset 3: const base::expected<viz::CopyOutputBitmapWithMetadata, std::string>&
David Bokan . resolved

We should add a `using CopyFromSurfaceResult = base:expected...` so that we can use `CopyFromSurfaceResult` instead of this everywhere. It's clearer and if we ever want to update e.g. string -> ErrorCode it would be a simpler change

Tianyang Xu

Good point. Done

Line 538, Patchset 3: result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap)),
David Bokan . resolved

Can you file a bug and leave TODOs in places like this...callers need to be updated to handle the returned error explicitly rather than (hopefully) checking for an empty bitmap

Tianyang Xu

Create a new ticket b/466199824

File chrome/browser/media/webrtc/tab_desktop_media_list.cc
Line 299, Patchset 3: if (!result.has_value()) {
// CopyFromSurface failed..
return;
}
David Bokan . resolved

This changes behavior...if we don't have a result we need to provide an empty one / empty bitmap below.

Tianyang Xu

Done

File chrome/browser/support_tool/screenshot_data_collector.cc
Line 297, Patchset 3: if (!result.has_value()) {

SupportToolError error = {
SupportToolErrorCode::kDataCollectorError,
David Bokan . resolved

ditto here and for other cases - aim to leave existing behavior unchanged

Tianyang Xu

Done

File content/browser/renderer_host/render_widget_host_impl.cc
Line 3567, Patchset 3: const SkBitmap& bitmap =
result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
David Bokan . resolved

This is a better pattern to ensure we don't change existing behavior...as noted above, with a TODO to explain that error reporting was added this code was written.

Tianyang Xu

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • David Bokan
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • 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: I684ab9ae721b681ede7acf87387b18120a2331ed
    Gerrit-Change-Number: 7229082
    Gerrit-PatchSet: 4
    Gerrit-Owner: Tianyang Xu <xtls...@google.com>
    Gerrit-CC: Andrew Rayskiy <green...@google.com>
    Gerrit-CC: David Bokan <bo...@chromium.org>
    Gerrit-CC: James Su <su...@chromium.org>
    Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-CC: Simon Hangl <sim...@google.com>
    Gerrit-Attention: David Bokan <bo...@chromium.org>
    Gerrit-Comment-Date: Fri, 05 Dec 2025 21:40:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: David Bokan <bo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    David Bokan (Gerrit)

    unread,
    Dec 9, 2025, 3:05:01 PM (7 days ago) Dec 9
    to Tianyang Xu, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
    Attention needed from Tianyang Xu

    David Bokan added 5 comments

    Patchset-level comments
    File-level comment, Patchset 13 (Latest):
    David Bokan . resolved

    Thanks - few small comments but looks good otherwise.

    Main question is whether we can be sure now that if we have a result it must be `!drawsNothing`? Unless we're certain it might be better to leave all the existing checks for it

    File chrome/browser/ui/views/tabs/dragging/tab_drag_controller.cc
    Line 1078, Patchset 13 (Parent): if (thumbnail.drawsNothing()) {
    return;
    }
    David Bokan . unresolved

    Do we guarantee now that if we have a bit map it must be `!drawsNothing`?

    File components/lens/tab_contextualization_controller.cc
    Line 321, Patchset 13 (Latest): // if (!result.has_value() || !image_options.has_value()) {
    // std::move(callback).Run(SkBitmap());
    // return;
    // }

    // const SkBitmap& screenshot = result->bitmap;
    David Bokan . unresolved

    Remove

    File components/viz/common/frame_sinks/copy_output_result.h
    Line 314, Patchset 13 (Latest): base::expected<CopyOutputBitmapWithMetadata, std::string>
    David Bokan . unresolved

    I think we should be able to use content::CopyFromSurface result here?

    File content/public/browser/render_widget_host_view.h
    Line 48, Patchset 13 (Latest):using CopyFromSurfaceResult =
    David Bokan . unresolved

    (Sorry, I know this will cause a lot of updates but hopefully you can search and replace it mechanically)

    I think it's unusual to include qualifiers like const/& in the alias. i.e. this should be:

    ```
    using CopyFromSurfaceResult = base::expected<...>;
    ```

    And call sites should use `const CopyFromSurfaceResult&`.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Tianyang Xu
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
      Gerrit-Change-Number: 7229082
      Gerrit-PatchSet: 13
      Gerrit-Owner: Tianyang Xu <xtls...@google.com>
      Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
      Gerrit-CC: Andrew Rayskiy <green...@google.com>
      Gerrit-CC: David Bokan <bo...@chromium.org>
      Gerrit-CC: James Su <su...@chromium.org>
      Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
      Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
      Gerrit-CC: Simon Hangl <sim...@google.com>
      Gerrit-Attention: Tianyang Xu <xtls...@google.com>
      Gerrit-Comment-Date: Tue, 09 Dec 2025 20:04:54 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Tianyang Xu (Gerrit)

      unread,
      Dec 10, 2025, 8:33:57 AM (6 days ago) Dec 10
      to Chromium LUCI CQ, David Bokan, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
      Attention needed from David Bokan

      Tianyang Xu added 5 comments

      File chrome/browser/ui/views/tabs/dragging/tab_drag_controller.cc
      Line 1078, Patchset 13 (Parent): if (thumbnail.drawsNothing()) {
      return;
      }
      David Bokan . resolved

      Do we guarantee now that if we have a bit map it must be `!drawsNothing`?

      Tianyang Xu

      Good point, right now it only report error when drawsNothing. But someday it might import more errors. Changed to using value_or() like other places.

      File components/lens/tab_contextualization_controller.cc
      Line 321, Patchset 13: // if (!result.has_value() || !image_options.has_value()) {

      // std::move(callback).Run(SkBitmap());
      // return;
      // }

      // const SkBitmap& screenshot = result->bitmap;
      David Bokan . resolved

      Remove

      Tianyang Xu

      Done

      File components/viz/common/frame_sinks/copy_output_result.h
      Line 314, Patchset 13: base::expected<CopyOutputBitmapWithMetadata, std::string>
      David Bokan . unresolved

      I think we should be able to use content::CopyFromSurface result here?

      Tianyang Xu

      I tried to change it to `content::CopyFromSurface`. But with including `"content/public/browser/render_widget_host_view.h"`, I always get the following error:
      ```
      ** Presubmit ERRORS: 1 **
      You added one or more #includes that violate checkdeps rules.
      components/viz/common/frame_sinks/copy_output_result.h
      Illegal include: "content/public/browser/render_widget_host_view.h"
      Because of no rule applying.
      ```
      I tried to add `content/public/browser` in `components/viz/common/frame_sinks/DEPS` and `components/viz/common/BUILD.gn` but just won't work. I wonder if it is because a reverse include, that viz cannot include anything from content.

      Or maybe we can put CopyFromSurface in `viz` with a different name?

      File content/public/browser/render_widget_host_view.h
      Line 48, Patchset 13:using CopyFromSurfaceResult =
      David Bokan . resolved

      (Sorry, I know this will cause a lot of updates but hopefully you can search and replace it mechanically)

      I think it's unusual to include qualifiers like const/& in the alias. i.e. this should be:

      ```
      using CopyFromSurfaceResult = base::expected<...>;
      ```

      And call sites should use `const CopyFromSurfaceResult&`.

      Tianyang Xu

      Np, it's not too hard to change with Gemini CLI

      File ui/android/delegated_frame_host_android.h
      Line 124, Patchset 14: void(const base::expected<viz::CopyOutputBitmapWithMetadata,
      std::string>&)> callback,
      Tianyang Xu . unresolved

      @bo...@chromium.org These two files are facing similar issue:
      They cannot import `render_widget_host_view.h` due to a loop deps.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • David Bokan
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
      Gerrit-Change-Number: 7229082
      Gerrit-PatchSet: 15
      Gerrit-Owner: Tianyang Xu <xtls...@google.com>
      Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
      Gerrit-CC: Andrew Rayskiy <green...@google.com>
      Gerrit-CC: David Bokan <bo...@chromium.org>
      Gerrit-CC: James Su <su...@chromium.org>
      Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
      Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
      Gerrit-CC: Simon Hangl <sim...@google.com>
      Gerrit-Attention: David Bokan <bo...@chromium.org>
      Gerrit-Comment-Date: Wed, 10 Dec 2025 13:33:49 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: David Bokan <bo...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      David Bokan (Gerrit)

      unread,
      Dec 10, 2025, 12:17:57 PM (6 days ago) Dec 10
      to Tianyang Xu, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
      Attention needed from Tianyang Xu

      David Bokan voted and added 3 comments

      Votes added by David Bokan

      Code-Review+1

      3 comments

      File components/viz/common/frame_sinks/copy_output_result.h
      Line 314, Patchset 13: base::expected<CopyOutputBitmapWithMetadata, std::string>
      David Bokan . resolved

      I think we should be able to use content::CopyFromSurface result here?

      Tianyang Xu

      I tried to change it to `content::CopyFromSurface`. But with including `"content/public/browser/render_widget_host_view.h"`, I always get the following error:
      ```
      ** Presubmit ERRORS: 1 **
      You added one or more #includes that violate checkdeps rules.
      components/viz/common/frame_sinks/copy_output_result.h
      Illegal include: "content/public/browser/render_widget_host_view.h"
      Because of no rule applying.
      ```
      I tried to add `content/public/browser` in `components/viz/common/frame_sinks/DEPS` and `components/viz/common/BUILD.gn` but just won't work. I wonder if it is because a reverse include, that viz cannot include anything from content.

      Or maybe we can put CopyFromSurface in `viz` with a different name?

      David Bokan

      I see, yes, it looks like this is because content depends on components/viz in at least a few places...not least of which is this use case in which RenderWidgetHostView issues a viz::CopyOutputRequest.

      This seems like inverted layering to me but is long standing and probably legacy. Viz might be a "special" component. Ok this is fine as is.

      File components/viz/common/frame_sinks/copy_output_result.cc
      Line 328, Patchset 15 (Latest): if (bitmap.drawsNothing()) {
      David Bokan . resolved

      Note: I expect this is likely going to be often what we receive so not super helpful - but lets land this CL as is since it's a lot of mechanical work to update call sites. In a followup CL we can instrument the viz code that fills out CopyOutputResult to also include an error reason which we can plumb through here.

      File ui/android/delegated_frame_host_android.h
      Line 124, Patchset 14: void(const base::expected<viz::CopyOutputBitmapWithMetadata,
      std::string>&)> callback,
      Tianyang Xu . resolved

      @bo...@chromium.org These two files are facing similar issue:
      They cannot import `render_widget_host_view.h` due to a loop deps.

      David Bokan

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Tianyang Xu
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
        Gerrit-Change-Number: 7229082
        Gerrit-PatchSet: 15
        Gerrit-Owner: Tianyang Xu <xtls...@google.com>
        Gerrit-Reviewer: David Bokan <bo...@chromium.org>
        Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
        Gerrit-CC: Andrew Rayskiy <green...@google.com>
        Gerrit-CC: James Su <su...@chromium.org>
        Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
        Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
        Gerrit-CC: Simon Hangl <sim...@google.com>
        Gerrit-Attention: Tianyang Xu <xtls...@google.com>
        Gerrit-Comment-Date: Wed, 10 Dec 2025 17:17:48 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: David Bokan <bo...@chromium.org>
        Comment-In-Reply-To: Tianyang Xu <xtls...@google.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Avi Drissman (Gerrit)

        unread,
        Dec 10, 2025, 1:36:03 PM (6 days ago) Dec 10
        to Tianyang Xu, Avi Drissman, Kyle Horimoto, Reilly Grant, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
        Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

        Avi Drissman voted Code-Review+1

        Code-Review+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrey Kosyakov
        • David Bokan
        • Duncan Mercer
        • Khushal Sagar
        • Kyle Horimoto
        • Reilly Grant
        • Tianyang Xu
        • thefrog
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
        Gerrit-Change-Number: 7229082
        Gerrit-PatchSet: 18
        Gerrit-Owner: Tianyang Xu <xtls...@google.com>
        Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
        Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
        Gerrit-Reviewer: David Bokan <bo...@chromium.org>
        Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
        Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
        Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
        Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
        Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
        Gerrit-Reviewer: thefrog <the...@chromium.org>
        Gerrit-CC: Andrew Rayskiy <green...@google.com>
        Gerrit-CC: James Su <su...@chromium.org>
        Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
        Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
        Gerrit-CC: Simon Hangl <sim...@google.com>
        Gerrit-Attention: thefrog <the...@chromium.org>
        Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
        Gerrit-Attention: Duncan Mercer <mer...@google.com>
        Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
        Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
        Gerrit-Attention: David Bokan <bo...@chromium.org>
        Gerrit-Attention: Reilly Grant <rei...@chromium.org>
        Gerrit-Attention: Tianyang Xu <xtls...@google.com>
        Gerrit-Comment-Date: Wed, 10 Dec 2025 18:35:52 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Reilly Grant (Gerrit)

        unread,
        Dec 10, 2025, 2:15:03 PM (6 days ago) Dec 10
        to Tianyang Xu, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
        Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Tianyang Xu and thefrog

        Reilly Grant voted and added 1 comment

        Votes added by Reilly Grant

        Code-Review+1

        1 comment

        Patchset-level comments
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrey Kosyakov
        • David Bokan
        • Duncan Mercer
        • Khushal Sagar
        • Kyle Horimoto
        • Tianyang Xu
        • thefrog
        Gerrit-Attention: Tianyang Xu <xtls...@google.com>
        Gerrit-Comment-Date: Wed, 10 Dec 2025 19:14:46 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Reilly Grant (Gerrit)

        unread,
        Dec 10, 2025, 2:16:53 PM (6 days ago) Dec 10
        to Tianyang Xu, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
        Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Tianyang Xu and thefrog

        Reilly Grant voted and added 1 comment

        Votes added by Reilly Grant

        Code-Review+0

        1 comment

        File headless/lib/browser/headless_web_contents_impl.cc
        Line 317, Patchset 18 (Latest): const SkBitmap& bitmap =
        result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
        Reilly Grant . unresolved

        I believe this is unsafe in the error case because `bitmap` is set to a reference to the temporary default value not the value that is stored by `result`.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Andrey Kosyakov
        • David Bokan
        • Duncan Mercer
        • Khushal Sagar
        • Kyle Horimoto
        • Tianyang Xu
        • thefrog
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Gerrit-Comment-Date: Wed, 10 Dec 2025 19:16:38 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          David Bokan (Gerrit)

          unread,
          Dec 10, 2025, 2:40:46 PM (6 days ago) Dec 10
          to Tianyang Xu, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Andrey Kosyakov, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Tianyang Xu and thefrog

          David Bokan added 1 comment

          File headless/lib/browser/headless_web_contents_impl.cc
          Line 317, Patchset 18 (Latest): const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          Reilly Grant . unresolved

          I believe this is unsafe in the error case because `bitmap` is set to a reference to the temporary default value not the value that is stored by `result`.

          David Bokan

          Yikes! Thanks for catching this! Yeah, that's a problem...

          Tianyang, the resolution will depend on call site...ideally if the callsite already checks for `drawsNothing()` like here, we can replace that with `result.has_value()`

          Otherwise you could construct an empty SkBitmap but you'll have to be careful about lifetime; if that gets passed into async callbacks without a copy you'd need to modify the callbacks to perhaps take CopyFromSurfaceResult instead.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrey Kosyakov
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Wed, 10 Dec 2025 19:40:37 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Tianyang Xu (Gerrit)

          unread,
          Dec 10, 2025, 3:07:16 PM (6 days ago) Dec 10
          to Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant and thefrog

          Tianyang Xu voted and added 1 comment

          Votes added by Tianyang Xu

          Commit-Queue+1

          1 comment

          File headless/lib/browser/headless_web_contents_impl.cc
          Line 317, Patchset 18 (Latest): const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          Reilly Grant . unresolved

          I believe this is unsafe in the error case because `bitmap` is set to a reference to the temporary default value not the value that is stored by `result`.

          David Bokan

          Yikes! Thanks for catching this! Yeah, that's a problem...

          Tianyang, the resolution will depend on call site...ideally if the callsite already checks for `drawsNothing()` like here, we can replace that with `result.has_value()`

          Otherwise you could construct an empty SkBitmap but you'll have to be careful about lifetime; if that gets passed into async callbacks without a copy you'd need to modify the callbacks to perhaps take CopyFromSurfaceResult instead.

          Tianyang Xu

          Actually I have checked this before using this `value_or()`. This is what I investigated:

          When result has no value, result.value_or(viz::CopyOutputBitmapWithMetadata()) produces a temporary viz::CopyOutputBitmapWithMetadata. The const SkBitmap& bitmap is bound to the bitmap member inside this temporary viz::CopyOutputBitmapWithMetadata. Because bitmap is a const reference, and it is bound to a member of a temporary object, according to the reference lifetime extension rules in the C++ Standard (often called 'reference lifetime extension'), the lifetime of this temporary viz::CopyOutputBitmapWithMetadata object will be extended until the bitmap const reference goes out of scope.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrey Kosyakov
          • David Bokan
          • Duncan Mercer
          • Khushal Sagar
          • Kyle Horimoto
          • Reilly Grant
          • thefrog
          Gerrit-Attention: David Bokan <bo...@chromium.org>
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Comment-Date: Wed, 10 Dec 2025 20:07:06 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: David Bokan <bo...@chromium.org>
          Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Tianyang Xu (Gerrit)

          unread,
          Dec 10, 2025, 3:11:27 PM (6 days ago) Dec 10
          to Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant and thefrog

          Tianyang Xu added 1 comment

          File headless/lib/browser/headless_web_contents_impl.cc
          Line 317, Patchset 18 (Latest): const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          Reilly Grant . unresolved

          I believe this is unsafe in the error case because `bitmap` is set to a reference to the temporary default value not the value that is stored by `result`.

          David Bokan

          Yikes! Thanks for catching this! Yeah, that's a problem...

          Tianyang, the resolution will depend on call site...ideally if the callsite already checks for `drawsNothing()` like here, we can replace that with `result.has_value()`

          Otherwise you could construct an empty SkBitmap but you'll have to be careful about lifetime; if that gets passed into async callbacks without a copy you'd need to modify the callbacks to perhaps take CopyFromSurfaceResult instead.

          Tianyang Xu

          Actually I have checked this before using this `value_or()`. This is what I investigated:

          When result has no value, result.value_or(viz::CopyOutputBitmapWithMetadata()) produces a temporary viz::CopyOutputBitmapWithMetadata. The const SkBitmap& bitmap is bound to the bitmap member inside this temporary viz::CopyOutputBitmapWithMetadata. Because bitmap is a const reference, and it is bound to a member of a temporary object, according to the reference lifetime extension rules in the C++ Standard (often called 'reference lifetime extension'), the lifetime of this temporary viz::CopyOutputBitmapWithMetadata object will be extended until the bitmap const reference goes out of scope.

          Tianyang Xu

          OK I did a dipper research, it turns out reference lifetime extension only apply to a top class/struct itself, but not to a member inside a temp object. So using a `const CopyOutputBitmapWithMetadata&` is safe with `value_or()`, but a `const SkBitmap&` is not. Let me see what I can do for this scenario.

          Gerrit-Comment-Date: Wed, 10 Dec 2025 20:11:10 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: David Bokan <bo...@chromium.org>
          Comment-In-Reply-To: Reilly Grant <rei...@chromium.org>
          Comment-In-Reply-To: Tianyang Xu <xtls...@google.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Andrey Kosyakov (Gerrit)

          unread,
          Dec 10, 2025, 6:44:54 PM (6 days ago) Dec 10
          to Tianyang Xu, Reilly Grant, Avi Drissman, Kyle Horimoto, Khushal Sagar, thefrog, Duncan Mercer, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

          Andrey Kosyakov added 1 comment

          File headless/lib/browser/headless_web_contents_impl.cc
          Line 322, Patchset 19 (Latest): if (bitmap.drawsNothing()) {
          Andrey Kosyakov . unresolved

          Should this and L321 instead be changed to result.has_value() now? This way we would be able to ditch L317 altogether and just use result->bitmap in L326.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Bokan
          • Duncan Mercer
          • Khushal Sagar
          • Kyle Horimoto
          • Reilly Grant
          • Tianyang Xu
          • thefrog
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • 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: I684ab9ae721b681ede7acf87387b18120a2331ed
          Gerrit-Change-Number: 7229082
          Gerrit-PatchSet: 19
          Gerrit-Owner: Tianyang Xu <xtls...@google.com>
          Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
          Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
          Gerrit-Reviewer: David Bokan <bo...@chromium.org>
          Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
          Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
          Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
          Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
          Gerrit-Reviewer: thefrog <the...@chromium.org>
          Gerrit-CC: Andrew Rayskiy <green...@google.com>
          Gerrit-CC: James Su <su...@chromium.org>
          Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
          Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
          Gerrit-CC: Simon Hangl <sim...@google.com>
          Gerrit-Attention: thefrog <the...@chromium.org>
          Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
          Gerrit-Attention: Duncan Mercer <mer...@google.com>
          Gerrit-Attention: David Bokan <bo...@chromium.org>
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Wed, 10 Dec 2025 23:44:37 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Duncan Mercer (Gerrit)

          unread,
          Dec 10, 2025, 8:23:37 PM (5 days ago) Dec 10
          to Tianyang Xu, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, Khushal Sagar, thefrog, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from David Bokan, Khushal Sagar, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

          Duncan Mercer voted and added 1 comment

          Votes added by Duncan Mercer

          Code-Review+1

          1 comment

          Patchset-level comments
          File-level comment, Patchset 19 (Latest):
          Duncan Mercer . resolved

          Lens LGTM. Didn't review the rest.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Bokan
          Gerrit-Attention: David Bokan <bo...@chromium.org>
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Thu, 11 Dec 2025 01:23:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Khushal Sagar (Gerrit)

          unread,
          Dec 10, 2025, 8:50:54 PM (5 days ago) Dec 10
          to Tianyang Xu, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, thefrog, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from David Bokan, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

          Khushal Sagar voted and added 1 comment

          Votes added by Khushal Sagar

          Code-Review+1

          1 comment

          File components/viz/common/frame_sinks/copy_output_result.h
          Line 309, Patchset 19 (Latest): // Returns a `base::expected` containing `CopyOutputBitmapWithMetadata`
          // on success, or an `std::string` error on failure.
          // `CopyOutputBitmapWithMetadata` contains a `SkBitmap` which can be used out
          // the scope of the `ScopedSkBitmap` and makes a copy of the content in
          // `CopyOutputResult` if needed.

          base::expected<CopyOutputBitmapWithMetadata, std::string>
          GetOutScopedBitmapAndMetadata() const;
          Khushal Sagar . unresolved

          nit: Do you need the viz API to change for this? The only possible failure is "no bitmap available" which can be done at the call-site. This is helpful if a follow up change will add more explicit errors from the GPU process back to the browser. Otherwise I'd prefer leaving this as-is for now.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • David Bokan
          Gerrit-Attention: David Bokan <bo...@chromium.org>
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Thu, 11 Dec 2025 01:50:39 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          David Bokan (Gerrit)

          unread,
          Dec 10, 2025, 8:57:01 PM (5 days ago) Dec 10
          to Tianyang Xu, Khushal Sagar, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, thefrog, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

          David Bokan added 1 comment

          File components/viz/common/frame_sinks/copy_output_result.h
          Line 309, Patchset 19 (Latest): // Returns a `base::expected` containing `CopyOutputBitmapWithMetadata`
          // on success, or an `std::string` error on failure.
          // `CopyOutputBitmapWithMetadata` contains a `SkBitmap` which can be used out
          // the scope of the `ScopedSkBitmap` and makes a copy of the content in
          // `CopyOutputResult` if needed.
          base::expected<CopyOutputBitmapWithMetadata, std::string>
          GetOutScopedBitmapAndMetadata() const;
          Khushal Sagar . unresolved

          nit: Do you need the viz API to change for this? The only possible failure is "no bitmap available" which can be done at the call-site. This is helpful if a follow up change will add more explicit errors from the GPU process back to the browser. Otherwise I'd prefer leaving this as-is for now.

          David Bokan

          I made a similar comment in https://chromium-review.googlesource.com/c/chromium/src/+/7229082/comment/eab99fca_17cf31dd/ but expect that we'll follow up here since there's not many early-outs before this...I expect the real failures will come from inside Viz.

          I like this split because this CL does the mostly mechanical changes to client call sites and the followup will actually instrument the viz paths...but given this adds no benefit without the followup perhaps we can wait until that's ready and land them together?

          Open in Gerrit

          Related details

          Attention is currently required from:
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Thu, 11 Dec 2025 01:56:51 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Khushal Sagar <khusha...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          David Bokan (Gerrit)

          unread,
          Dec 10, 2025, 10:25:32 PM (5 days ago) Dec 10
          to Tianyang Xu, Khushal Sagar, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, thefrog, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

          David Bokan added 9 comments

          File chrome/browser/android/compositor/tab_content_manager.cc
          Line 93, Patchset 19 (Latest): if (bitmap.drawsNothing() || drop_after_readback_) {
          David Bokan . unresolved

          nit: check result.has_value() here.

          File chrome/browser/media/webrtc/tab_desktop_media_list.cc
          Line 280, Patchset 19 (Latest): if (bitmap.drawsNothing() && remaining_retries > 0) {
          David Bokan . unresolved

          check result.has_value() instead.

          File chrome/browser/permissions/prediction_service/permissions_ai_ui_selector.cc
          Line 813, Patchset 19 (Latest): return result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . unresolved

          I think this won't work in the failure case? Because this is a temporary but OnSnapshotTakenForOnDeviceModel takes the argument by ref. I think we can modify OnSnapshotTakenForOnDeviceModel to take a base::expected or SkBitmap* with nullptr for error case.

          File chrome/browser/ui/lens/lens_overlay_blur_layer_delegate.cc
          Line 162, Patchset 19 (Latest): if (bitmap.drawsNothing() || layer_size.width() * layer_size.height() <= 0 ||
          David Bokan . unresolved

          Check result.has_value() instead and then you can use `result->bitmap`

          File chrome/browser/ui/lens/lens_search_contextualization_controller.cc
          Line 1012, Patchset 19 (Latest): const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . unresolved

          I suspect this pattern still leads to a dangling ref because, IIUC, the temporary object lifetime extension applies only if you're holding a ref to the temporary object itself. i.e. here the `CopyOutputBitmapWithMetadata` will be destroyed (along with its inner `bitmap`) at the end of the line, despite you holding a ref to the inner `bitmap`. I think you'd either have to hold a ref to `CopyOutputBitmapWithMetadata` or do something like:

          ```
          const SkBitmap& bitmap = result.has_value() ? result->bitmap : SkBitmap()
          ```

          Please update all uses of this pattern

          Line 1028, Patchset 19 (Latest): ++screenshot_attempt_id_, bitmap, std::move(callback)));
          David Bokan . unresolved

          Hmm, this seems suspect before your change...this is a reply callback for a mojo call (so async) but takes the bitmap by ref...

          I suspect GetPdfCurrentPage (and inner uses) should be taking the SkBitmap by value (which shares buffers on construction using ref-counting)...perhaps @mer...@google.com can comment on the way forward here...

          File chrome/browser/ui/omnibox/chrome_omnibox_client.cc
          Line 623, Patchset 19 (Latest): // error case.
          return result
          .value_or(viz::CopyOutputBitmapWithMetadata())
          .bitmap;
          })
          David Bokan . unresolved

          Here also, we'll need to pass a nullptr or something else in the failure case since the on_bitmap_fetched callback takes by-ref.

          File chrome/browser/ui/thumbnails/thumbnail_tab_helper.cc
          Line 302, Patchset 19 (Latest): // TODO(crbug.com/466199824): Update callsite to handle error case.

          const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . unresolved

          StoreThumbnail just early outs if we have no value...I think we can do that here rather than passing in the empty ref (after the UMA_HISTOGRAM to preserve behavior), i.e.:

          ```
          UMA_HISTOGRAM...
          if (!result.has_value()) {
          return;
          }
          StoreThumbnail(..., result->bitmap, ...)
          ```
          File headless/lib/browser/headless_web_contents_impl.cc
          Line 322, Patchset 19 (Latest): if (bitmap.drawsNothing()) {
          Andrey Kosyakov . unresolved

          Should this and L321 instead be changed to result.has_value() now? This way we would be able to ditch L317 altogether and just use result->bitmap in L326.

          David Bokan

          +1 we should do this wherever nearby code is checking `drawsNothing`

          Gerrit-Comment-Date: Thu, 11 Dec 2025 03:25:19 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          thefrog (Gerrit)

          unread,
          Dec 11, 2025, 10:26:12 AM (5 days ago) Dec 11
          to Tianyang Xu, Khushal Sagar, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Kyle Horimoto, Reilly Grant and Tianyang Xu

          thefrog added 1 comment

          File components/safe_browsing/content/browser/password_protection/password_protection_request_content.cc
          Line 419, Patchset 19 (Latest): result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          thefrog . unresolved

          I think this has the same issue discussed in other comments right?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Kyle Horimoto
          • Reilly Grant
          • Tianyang Xu
          Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
          Gerrit-Attention: Reilly Grant <rei...@chromium.org>
          Gerrit-Attention: Tianyang Xu <xtls...@google.com>
          Gerrit-Comment-Date: Thu, 11 Dec 2025 15:25:56 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Tianyang Xu (Gerrit)

          unread,
          Dec 11, 2025, 6:12:58 PM (5 days ago) Dec 11
          to Khushal Sagar, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, Andrey Kosyakov, thefrog, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
          Attention needed from Andrey Kosyakov, Avi Drissman, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant and thefrog

          Tianyang Xu added 8 comments

          File chrome/browser/android/compositor/tab_content_manager.cc
          Line 93, Patchset 19: if (bitmap.drawsNothing() || drop_after_readback_) {
          David Bokan . resolved

          nit: check result.has_value() here.

          Tianyang Xu

          Done

          File chrome/browser/media/webrtc/tab_desktop_media_list.cc
          Line 280, Patchset 19: if (bitmap.drawsNothing() && remaining_retries > 0) {
          David Bokan . resolved

          check result.has_value() instead.

          Tianyang Xu

          Done

          File chrome/browser/permissions/prediction_service/permissions_ai_ui_selector.cc
          Line 813, Patchset 19: return result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . resolved

          I think this won't work in the failure case? Because this is a temporary but OnSnapshotTakenForOnDeviceModel takes the argument by ref. I think we can modify OnSnapshotTakenForOnDeviceModel to take a base::expected or SkBitmap* with nullptr for error case.

          Tianyang Xu

          Changed to base::expected<SkBitmap, string> in OnSnapshotTakenForOnDeviceModel

          File chrome/browser/ui/lens/lens_overlay_blur_layer_delegate.cc
          Line 162, Patchset 19: if (bitmap.drawsNothing() || layer_size.width() * layer_size.height() <= 0 ||
          David Bokan . resolved

          Check result.has_value() instead and then you can use `result->bitmap`

          Tianyang Xu

          Done

          File chrome/browser/ui/lens/lens_search_contextualization_controller.cc
          Line 1012, Patchset 19: const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . resolved

          I suspect this pattern still leads to a dangling ref because, IIUC, the temporary object lifetime extension applies only if you're holding a ref to the temporary object itself. i.e. here the `CopyOutputBitmapWithMetadata` will be destroyed (along with its inner `bitmap`) at the end of the line, despite you holding a ref to the inner `bitmap`. I think you'd either have to hold a ref to `CopyOutputBitmapWithMetadata` or do something like:

          ```
          const SkBitmap& bitmap = result.has_value() ? result->bitmap : SkBitmap()
          ```

          Please update all uses of this pattern

          Tianyang Xu

          Yep, this is what I investigated, that the const ref should not be used on the bitmap which is part of the temp CopyOutputBitmapWithMetadata().

          File chrome/browser/ui/thumbnails/thumbnail_tab_helper.cc
          Line 302, Patchset 19: // TODO(crbug.com/466199824): Update callsite to handle error case.

          const SkBitmap& bitmap =
          result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          David Bokan . resolved

          StoreThumbnail just early outs if we have no value...I think we can do that here rather than passing in the empty ref (after the UMA_HISTOGRAM to preserve behavior), i.e.:

          ```
          UMA_HISTOGRAM...
          if (!result.has_value()) {
          return;
          }
          StoreThumbnail(..., result->bitmap, ...)
          ```
          Tianyang Xu

          Done

          File components/safe_browsing/content/browser/password_protection/password_protection_request_content.cc
          Line 419, Patchset 19: result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
          thefrog . resolved

          I think this has the same issue discussed in other comments right?

          Tianyang Xu

          Yes, changed to
          const SkBitmap& bitmap = result.has_value() ? result->bitmap : SkBitmap();
          to avoid dangling reference.

          File headless/lib/browser/headless_web_contents_impl.cc
          Line 322, Patchset 19: if (bitmap.drawsNothing()) {
          Andrey Kosyakov . resolved

          Should this and L321 instead be changed to result.has_value() now? This way we would be able to ditch L317 altogether and just use result->bitmap in L326.

          David Bokan

          +1 we should do this wherever nearby code is checking `drawsNothing`

          Tianyang Xu

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Andrey Kosyakov
          • Avi Drissman
          • David Bokan
          • Duncan Mercer
          • Khushal Sagar
          • Kyle Horimoto
          • Reilly Grant
          • thefrog
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
            Gerrit-Change-Number: 7229082
            Gerrit-PatchSet: 20
            Gerrit-Owner: Tianyang Xu <xtls...@google.com>
            Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
            Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
            Gerrit-Reviewer: David Bokan <bo...@chromium.org>
            Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
            Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
            Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
            Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
            Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
            Gerrit-Reviewer: thefrog <the...@chromium.org>
            Gerrit-CC: Andrew Rayskiy <green...@google.com>
            Gerrit-CC: James Su <su...@chromium.org>
            Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
            Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
            Gerrit-CC: Simon Hangl <sim...@google.com>
            Gerrit-Attention: thefrog <the...@chromium.org>
            Gerrit-Attention: Duncan Mercer <mer...@google.com>
            Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
            Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
            Gerrit-Attention: David Bokan <bo...@chromium.org>
            Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
            Gerrit-Attention: Avi Drissman <a...@chromium.org>
            Gerrit-Attention: Reilly Grant <rei...@chromium.org>
            Gerrit-Comment-Date: Thu, 11 Dec 2025 23:12:52 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: thefrog <the...@chromium.org>
            Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
            Comment-In-Reply-To: David Bokan <bo...@chromium.org>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Andrey Kosyakov (Gerrit)

            unread,
            Dec 11, 2025, 6:28:54 PM (5 days ago) Dec 11
            to Tianyang Xu, Khushal Sagar, Duncan Mercer, Reilly Grant, Avi Drissman, Kyle Horimoto, thefrog, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
            Attention needed from Avi Drissman, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

            Andrey Kosyakov voted and added 2 comments

            Votes added by Andrey Kosyakov

            Code-Review+1

            2 comments

            Patchset-level comments
            File-level comment, Patchset 20 (Latest):
            Andrey Kosyakov . resolved

            headless/ lgtm % comment

            File headless/lib/browser/headless_web_contents_impl.cc
            Line 317, Patchset 20 (Latest): const SkBitmap& bitmap = result.has_value() ? result->bitmap : SkBitmap();
            Andrey Kosyakov . unresolved

            you don't need this here anymore, just inline result->bitmap() in L326 since at that point we already know it has value.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Avi Drissman
            • David Bokan
            • Duncan Mercer
            • Khushal Sagar
            • Kyle Horimoto
            • Reilly Grant
            • Tianyang Xu
            • thefrog
            Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Owners
              • requirement satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement satisfiedReview-Enforcement
              Gerrit-Attention: David Bokan <bo...@chromium.org>
              Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
              Gerrit-Attention: Avi Drissman <a...@chromium.org>
              Gerrit-Attention: Reilly Grant <rei...@chromium.org>
              Gerrit-Attention: Tianyang Xu <xtls...@google.com>
              Gerrit-Comment-Date: Thu, 11 Dec 2025 23:28:43 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Reilly Grant (Gerrit)

              unread,
              Dec 11, 2025, 7:24:49 PM (5 days ago) Dec 11
              to Tianyang Xu, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Duncan Mercer, Avi Drissman, Kyle Horimoto, thefrog, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
              Attention needed from David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Tianyang Xu and thefrog

              Reilly Grant voted and added 1 comment

              Votes added by Reilly Grant

              Code-Review+1

              1 comment

              Patchset-level comments
              Reilly Grant . resolved

              //extensions LGTM

              Open in Gerrit

              Related details

              Attention is currently required from:
              • David Bokan
              • Duncan Mercer
              • Khushal Sagar
              • Kyle Horimoto
              • Tianyang Xu
              • thefrog
              Gerrit-Attention: Tianyang Xu <xtls...@google.com>
              Gerrit-Comment-Date: Fri, 12 Dec 2025 00:24:36 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              thefrog (Gerrit)

              unread,
              Dec 12, 2025, 10:13:59 AM (4 days ago) Dec 12
              to Tianyang Xu, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Duncan Mercer, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
              Attention needed from David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto and Tianyang Xu

              thefrog voted and added 1 comment

              Votes added by thefrog

              Code-Review+1

              1 comment

              Patchset-level comments
              thefrog . resolved

              safe_browsing LGTM

              Open in Gerrit

              Related details

              Attention is currently required from:
              • David Bokan
              • Duncan Mercer
              • Khushal Sagar
              • Kyle Horimoto
              • Tianyang Xu
              Gerrit-Attention: Duncan Mercer <mer...@google.com>
              Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
              Gerrit-Attention: David Bokan <bo...@chromium.org>
              Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
              Gerrit-Attention: Tianyang Xu <xtls...@google.com>
              Gerrit-Comment-Date: Fri, 12 Dec 2025 15:13:47 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Tianyang Xu (Gerrit)

              unread,
              Dec 12, 2025, 2:01:15 PM (4 days ago) Dec 12
              to thefrog, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Duncan Mercer, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
              Attention needed from Andrey Kosyakov, David Bokan, Duncan Mercer, Khushal Sagar, Kyle Horimoto, Reilly Grant and thefrog

              Tianyang Xu added 1 comment

              File headless/lib/browser/headless_web_contents_impl.cc
              Line 317, Patchset 20: const SkBitmap& bitmap = result.has_value() ? result->bitmap : SkBitmap();
              Andrey Kosyakov . resolved

              you don't need this here anymore, just inline result->bitmap() in L326 since at that point we already know it has value.

              Tianyang Xu

              Yeah good catch, thanks

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Andrey Kosyakov
              • David Bokan
              • Duncan Mercer
              • Khushal Sagar
              • Kyle Horimoto
              • Reilly Grant
              • thefrog
              Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement is not 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: I684ab9ae721b681ede7acf87387b18120a2331ed
                Gerrit-Change-Number: 7229082
                Gerrit-PatchSet: 22
                Gerrit-Owner: Tianyang Xu <xtls...@google.com>
                Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
                Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
                Gerrit-Reviewer: David Bokan <bo...@chromium.org>
                Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
                Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
                Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
                Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
                Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
                Gerrit-Reviewer: thefrog <the...@chromium.org>
                Gerrit-CC: Andrew Rayskiy <green...@google.com>
                Gerrit-CC: James Su <su...@chromium.org>
                Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
                Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                Gerrit-CC: Simon Hangl <sim...@google.com>
                Gerrit-Attention: thefrog <the...@chromium.org>
                Gerrit-Attention: Duncan Mercer <mer...@google.com>
                Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
                Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                Gerrit-Attention: David Bokan <bo...@chromium.org>
                Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                Gerrit-Attention: Reilly Grant <rei...@chromium.org>
                Gerrit-Comment-Date: Fri, 12 Dec 2025 19:01:05 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Duncan Mercer (Gerrit)

                unread,
                Dec 12, 2025, 2:18:00 PM (4 days ago) Dec 12
                to Tianyang Xu, thefrog, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
                Attention needed from Andrey Kosyakov, David Bokan, Khushal Sagar, Kyle Horimoto, Reilly Grant, Tianyang Xu and thefrog

                Duncan Mercer voted and added 1 comment

                Votes added by Duncan Mercer

                Code-Review+1

                1 comment

                File chrome/browser/ui/lens/lens_search_contextualization_controller.cc
                Line 1028, Patchset 19: ++screenshot_attempt_id_, bitmap, std::move(callback)));
                David Bokan . unresolved

                Hmm, this seems suspect before your change...this is a reply callback for a mojo call (so async) but takes the bitmap by ref...

                I suspect GetPdfCurrentPage (and inner uses) should be taking the SkBitmap by value (which shares buffers on construction using ref-counting)...perhaps @mer...@google.com can comment on the way forward here...

                Duncan Mercer

                Hmmm. This is a well tested path thats never caused issues. However, if you think moving to passing by value is safer, SGTM.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Andrey Kosyakov
                • David Bokan
                • Khushal Sagar
                • Kyle Horimoto
                • Reilly Grant
                • Tianyang Xu
                • thefrog
                Submit Requirements:
                  • requirement satisfiedCode-Coverage
                  • requirement is not satisfiedCode-Owners
                  • requirement satisfiedCode-Review
                  • requirement is not satisfiedNo-Unresolved-Comments
                  • requirement satisfiedReview-Enforcement
                  Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Attention: David Bokan <bo...@chromium.org>
                  Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Attention: Reilly Grant <rei...@chromium.org>
                  Gerrit-Attention: Tianyang Xu <xtls...@google.com>
                  Gerrit-Comment-Date: Fri, 12 Dec 2025 19:17:47 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: Yes
                  Comment-In-Reply-To: David Bokan <bo...@chromium.org>
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  thefrog (Gerrit)

                  unread,
                  Dec 12, 2025, 6:24:44 PM (4 days ago) Dec 12
                  to Tianyang Xu, Duncan Mercer, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
                  Attention needed from Andrey Kosyakov, David Bokan, Khushal Sagar, Kyle Horimoto, Reilly Grant and Tianyang Xu

                  thefrog voted and added 1 comment

                  Votes added by thefrog

                  Code-Review+1

                  1 comment

                  Patchset-level comments
                  File-level comment, Patchset 22 (Latest):
                  thefrog . resolved

                  safe_browsing/ is unchanged from my last +1

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Andrey Kosyakov
                  • David Bokan
                  • Khushal Sagar
                  • Kyle Horimoto
                  • Reilly Grant
                  • Tianyang Xu
                  Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Attention: David Bokan <bo...@chromium.org>
                  Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Attention: Reilly Grant <rei...@chromium.org>
                  Gerrit-Attention: Tianyang Xu <xtls...@google.com>
                  Gerrit-Comment-Date: Fri, 12 Dec 2025 23:24:35 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: Yes
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Tianyang Xu (Gerrit)

                  unread,
                  Dec 15, 2025, 1:50:52 PM (18 hours ago) Dec 15
                  to thefrog, Duncan Mercer, Reilly Grant, Andrey Kosyakov, Khushal Sagar, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
                  Attention needed from Andrey Kosyakov, David Bokan, Khushal Sagar, Kyle Horimoto and Reilly Grant

                  Tianyang Xu added 3 comments

                  File chrome/browser/ui/lens/lens_search_contextualization_controller.cc
                  Line 1028, Patchset 19: ++screenshot_attempt_id_, bitmap, std::move(callback)));
                  David Bokan . resolved

                  Hmm, this seems suspect before your change...this is a reply callback for a mojo call (so async) but takes the bitmap by ref...

                  I suspect GetPdfCurrentPage (and inner uses) should be taking the SkBitmap by value (which shares buffers on construction using ref-counting)...perhaps @mer...@google.com can comment on the way forward here...

                  Duncan Mercer

                  Hmmm. This is a well tested path thats never caused issues. However, if you think moving to passing by value is safer, SGTM.

                  Tianyang Xu

                  Done

                  File chrome/browser/ui/omnibox/chrome_omnibox_client.cc
                  Line 623, Patchset 19: // error case.

                  return result
                  .value_or(viz::CopyOutputBitmapWithMetadata())
                  .bitmap;
                  })
                  David Bokan . resolved

                  Here also, we'll need to pass a nullptr or something else in the failure case since the on_bitmap_fetched callback takes by-ref.

                  Tianyang Xu

                  Changed to a value copy

                  File headless/lib/browser/headless_web_contents_impl.cc
                  Line 317, Patchset 18: const SkBitmap& bitmap =
                  result.value_or(viz::CopyOutputBitmapWithMetadata()).bitmap;
                  Reilly Grant . resolved

                  I believe this is unsafe in the error case because `bitmap` is set to a reference to the temporary default value not the value that is stored by `result`.

                  David Bokan

                  Yikes! Thanks for catching this! Yeah, that's a problem...

                  Tianyang, the resolution will depend on call site...ideally if the callsite already checks for `drawsNothing()` like here, we can replace that with `result.has_value()`

                  Otherwise you could construct an empty SkBitmap but you'll have to be careful about lifetime; if that gets passed into async callbacks without a copy you'd need to modify the callbacks to perhaps take CopyFromSurfaceResult instead.

                  Tianyang Xu

                  Actually I have checked this before using this `value_or()`. This is what I investigated:

                  When result has no value, result.value_or(viz::CopyOutputBitmapWithMetadata()) produces a temporary viz::CopyOutputBitmapWithMetadata. The const SkBitmap& bitmap is bound to the bitmap member inside this temporary viz::CopyOutputBitmapWithMetadata. Because bitmap is a const reference, and it is bound to a member of a temporary object, according to the reference lifetime extension rules in the C++ Standard (often called 'reference lifetime extension'), the lifetime of this temporary viz::CopyOutputBitmapWithMetadata object will be extended until the bitmap const reference goes out of scope.

                  Tianyang Xu

                  OK I did a dipper research, it turns out reference lifetime extension only apply to a top class/struct itself, but not to a member inside a temp object. So using a `const CopyOutputBitmapWithMetadata&` is safe with `value_or()`, but a `const SkBitmap&` is not. Let me see what I can do for this scenario.

                  Tianyang Xu

                  Done

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Andrey Kosyakov
                  • David Bokan
                  • Khushal Sagar
                  • Kyle Horimoto
                  • Reilly Grant
                  Submit Requirements:
                  • requirement satisfiedCode-Coverage
                  • requirement is not satisfiedCode-Owners
                  • requirement satisfiedCode-Review
                  • requirement is not satisfiedNo-Unresolved-Comments
                  • 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: I684ab9ae721b681ede7acf87387b18120a2331ed
                  Gerrit-Change-Number: 7229082
                  Gerrit-PatchSet: 24
                  Gerrit-Owner: Tianyang Xu <xtls...@google.com>
                  Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
                  Gerrit-Reviewer: David Bokan <bo...@chromium.org>
                  Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
                  Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
                  Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
                  Gerrit-Reviewer: thefrog <the...@chromium.org>
                  Gerrit-CC: Andrew Rayskiy <green...@google.com>
                  Gerrit-CC: James Su <su...@chromium.org>
                  Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
                  Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                  Gerrit-CC: Simon Hangl <sim...@google.com>
                  Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Attention: David Bokan <bo...@chromium.org>
                  Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Attention: Reilly Grant <rei...@chromium.org>
                  Gerrit-Comment-Date: Mon, 15 Dec 2025 18:50:43 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Comment-In-Reply-To: Duncan Mercer <mer...@google.com>
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Reilly Grant (Gerrit)

                  unread,
                  Dec 15, 2025, 2:46:56 PM (17 hours ago) Dec 15
                  to Tianyang Xu, Reilly Grant, Nihar Majmudar, thefrog, Duncan Mercer, Andrey Kosyakov, Khushal Sagar, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
                  Attention needed from Andrey Kosyakov, David Bokan, Khushal Sagar, Kyle Horimoto, Nihar Majmudar and Tianyang Xu

                  Reilly Grant voted and added 1 comment

                  Votes added by Reilly Grant

                  Code-Review+1

                  1 comment

                  Patchset-level comments
                  File-level comment, Patchset 24 (Latest):
                  Reilly Grant . resolved

                  //extensions still LGTM

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Andrey Kosyakov
                  • David Bokan
                  • Khushal Sagar
                  • Kyle Horimoto
                  • Nihar Majmudar
                  • Tianyang Xu
                  Submit Requirements:
                  • requirement satisfiedCode-Coverage
                  • requirement is not satisfiedCode-Owners
                  • requirement satisfiedCode-Review
                  • requirement is not satisfiedNo-Unresolved-Comments
                  • 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: I684ab9ae721b681ede7acf87387b18120a2331ed
                  Gerrit-Change-Number: 7229082
                  Gerrit-PatchSet: 24
                  Gerrit-Owner: Tianyang Xu <xtls...@google.com>
                  Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
                  Gerrit-Reviewer: David Bokan <bo...@chromium.org>
                  Gerrit-Reviewer: Duncan Mercer <mer...@google.com>
                  Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Reviewer: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Reviewer: Nihar Majmudar <nih...@google.com>
                  Gerrit-Reviewer: Reilly Grant <rei...@chromium.org>
                  Gerrit-Reviewer: Tianyang Xu <xtls...@google.com>
                  Gerrit-Reviewer: thefrog <the...@chromium.org>
                  Gerrit-CC: Andrew Rayskiy <green...@google.com>
                  Gerrit-CC: James Su <su...@chromium.org>
                  Gerrit-CC: Permissions Reviews <permissio...@chromium.org>
                  Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                  Gerrit-CC: Simon Hangl <sim...@google.com>
                  Gerrit-Attention: Nihar Majmudar <nih...@google.com>
                  Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
                  Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                  Gerrit-Attention: David Bokan <bo...@chromium.org>
                  Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                  Gerrit-Attention: Tianyang Xu <xtls...@google.com>
                  Gerrit-Comment-Date: Mon, 15 Dec 2025 19:46:45 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: Yes
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Khushal Sagar (Gerrit)

                  unread,
                  Dec 15, 2025, 4:49:48 PM (15 hours ago) Dec 15
                  to Tianyang Xu, Reilly Grant, Nihar Majmudar, thefrog, Duncan Mercer, Andrey Kosyakov, Avi Drissman, Kyle Horimoto, David Bokan, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, Andrew Rayskiy, Permissions Reviews, Rijubrata Bhaumik, Simon Hangl, James Su, christia...@chromium.org, oshima...@chromium.org, mac-r...@chromium.org, headless...@chromium.org, omnibox-...@chromium.org, jdonnel...@chromium.org, alexmo...@chromium.org, andysjl...@chromium.org, cc-...@chromium.org, chfreme...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, chromium-a...@chromium.org, creis...@chromium.org, dewitt...@chromium.org, druber...@chromium.org, extension...@chromium.org, feature-me...@chromium.org, jbauma...@chromium.org, jophba...@chromium.org, keithle...@chromium.org, lens-chrome...@google.com, mercer...@google.com, mfoltz+wa...@chromium.org, mfoltz+wa...@chromium.org, navigation...@chromium.org, nona+...@chromium.org, nwoked...@chromium.org, rmcelra...@chromium.org, shuche...@chromium.org, stanfie...@google.com, tranbaod...@chromium.org, vakh+safe_br...@chromium.org, xinghui...@chromium.org, yhanad...@chromium.org, zackha...@chromium.org
                  Attention needed from Andrey Kosyakov, David Bokan, Kyle Horimoto, Nihar Majmudar and Tianyang Xu

                  Khushal Sagar voted and added 2 comments

                  Votes added by Khushal Sagar

                  Code-Review+1

                  2 comments

                  Patchset-level comments
                  Khushal Sagar . resolved

                  viz LGTM.

                  File components/viz/common/frame_sinks/copy_output_result.h
                  Line 309, Patchset 19: // Returns a `base::expected` containing `CopyOutputBitmapWithMetadata`

                  // on success, or an `std::string` error on failure.
                  // `CopyOutputBitmapWithMetadata` contains a `SkBitmap` which can be used out
                  // the scope of the `ScopedSkBitmap` and makes a copy of the content in
                  // `CopyOutputResult` if needed.
                  base::expected<CopyOutputBitmapWithMetadata, std::string>
                  GetOutScopedBitmapAndMetadata() const;
                  Khushal Sagar . resolved

                  nit: Do you need the viz API to change for this? The only possible failure is "no bitmap available" which can be done at the call-site. This is helpful if a follow up change will add more explicit errors from the GPU process back to the browser. Otherwise I'd prefer leaving this as-is for now.

                  David Bokan

                  I made a similar comment in https://chromium-review.googlesource.com/c/chromium/src/+/7229082/comment/eab99fca_17cf31dd/ but expect that we'll follow up here since there's not many early-outs before this...I expect the real failures will come from inside Viz.

                  I like this split because this CL does the mostly mechanical changes to client call sites and the followup will actually instrument the viz paths...but given this adds no benefit without the followup perhaps we can wait until that's ready and land them together?

                  Khushal Sagar

                  If the plan is to get more specific errors from the Viz code then this LGTM. I'm ok landing this now.

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Andrey Kosyakov
                  • David Bokan
                  • Kyle Horimoto
                  • Nihar Majmudar
                  • Tianyang Xu
                    Submit Requirements:
                      • requirement satisfiedCode-Coverage
                      • requirement is not satisfiedCode-Owners
                      • requirement satisfiedCode-Review
                      • requirement satisfiedReview-Enforcement
                      Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
                      Gerrit-Attention: David Bokan <bo...@chromium.org>
                      Gerrit-Attention: Kyle Horimoto <khor...@chromium.org>
                      Gerrit-Attention: Tianyang Xu <xtls...@google.com>
                      Gerrit-Comment-Date: Mon, 15 Dec 2025 21:49:32 +0000
                      Gerrit-HasComments: Yes
                      Gerrit-Has-Labels: Yes
                      Comment-In-Reply-To: Khushal Sagar <khusha...@chromium.org>
                      Comment-In-Reply-To: David Bokan <bo...@chromium.org>
                      satisfied_requirement
                      unsatisfied_requirement
                      open
                      diffy
                      Reply all
                      Reply to author
                      Forward
                      0 new messages