blink: Fix squashed image when copying video frames [chromium/src : main]

0 views
Skip to first unread message

Vikram Pasupathy (Gerrit)

unread,
Jun 26, 2026, 3:26:18 PM (2 days ago) Jun 26
to Ted (Chromium) Meyer, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
Attention needed from Ted (Chromium) Meyer

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Ted (Chromium) Meyer
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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
Gerrit-Change-Number: 8008618
Gerrit-PatchSet: 2
Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
Gerrit-Attention: Ted (Chromium) Meyer <tmath...@chromium.org>
Gerrit-Comment-Date: Fri, 26 Jun 2026 19:26:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Ted (Chromium) Meyer (Gerrit)

unread,
Jun 26, 2026, 4:27:06 PM (2 days ago) Jun 26
to Vikram Pasupathy, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
Attention needed from Vikram Pasupathy

Ted (Chromium) Meyer added 3 comments

File third_party/blink/renderer/core/html/media/html_video_element.cc
Line 907, Patchset 2 (Latest): media_video_frame->metadata().transformation = transform;
Ted (Chromium) Meyer . unresolved

AFAIK, media_video_frame is shared across threads (the compositor uses it), and this might have some data race implications. It might also be fine, since the frame would have had to be rendered before it can be clicked on for this operation by the user, but I suppose there could be some weirdness lurking here. You can use VideoFrame::WrapVideoFrame to make a shallow copy and set the metadata there, I think.

Line 899, Patchset 2 (Latest): wmp_natural_size = wmp->NaturalSize();

// The underlying VideoFrame may have been stripped of its transformation
// metadata by the decoder or hardware buffer pipeline. If the frame lacks
// a rotation but the WebMediaPlayer's pipeline metadata knows it exists,
// we must inherit it.
if (transform.rotation == media::VIDEO_ROTATION_0) {
transform = wmp->GetVideoTransformation();
media_video_frame->metadata().transformation = transform;
}

if (media_video_frame->visible_rect().size() == wmp_natural_size &&
(transform.rotation == media::VIDEO_ROTATION_90 ||
transform.rotation == media::VIDEO_ROTATION_270)) {
// Clear the transformation metadata to prevent double rotation during
// paint
media_video_frame->metadata().transformation = media::kNoTransformation;
transform = media::kNoTransformation;
}
Ted (Chromium) Meyer . unresolved

Should you just move this into condition on line 876?

Line 936, Patchset 2 (Latest): if (!raster_context_provider) {
if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) {
raster_context_provider =
wrapper->ContextProvider().RasterContextProvider();
}
}
Ted (Chromium) Meyer . unresolved

This looks identical to line 885-889, is RasterContextProvider() expected to return null the first time and non-null after that?

Open in Gerrit

Related details

Attention is currently required from:
  • Vikram Pasupathy
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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
    Gerrit-Change-Number: 8008618
    Gerrit-PatchSet: 2
    Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
    Gerrit-Attention: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Jun 2026 20:26:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vikram Pasupathy (Gerrit)

    unread,
    Jun 26, 2026, 7:18:38 PM (2 days ago) Jun 26
    to Ted (Chromium) Meyer, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
    Attention needed from Ted (Chromium) Meyer

    Vikram Pasupathy added 3 comments

    File third_party/blink/renderer/core/html/media/html_video_element.cc
    Line 907, Patchset 2: media_video_frame->metadata().transformation = transform;
    Ted (Chromium) Meyer . resolved

    AFAIK, media_video_frame is shared across threads (the compositor uses it), and this might have some data race implications. It might also be fine, since the frame would have had to be rendered before it can be clicked on for this operation by the user, but I suppose there could be some weirdness lurking here. You can use VideoFrame::WrapVideoFrame to make a shallow copy and set the metadata there, I think.

    Vikram Pasupathy

    Done

    Line 899, Patchset 2: wmp_natural_size = wmp->NaturalSize();


    // The underlying VideoFrame may have been stripped of its transformation
    // metadata by the decoder or hardware buffer pipeline. If the frame lacks
    // a rotation but the WebMediaPlayer's pipeline metadata knows it exists,
    // we must inherit it.
    if (transform.rotation == media::VIDEO_ROTATION_0) {
    transform = wmp->GetVideoTransformation();
    media_video_frame->metadata().transformation = transform;
    }

    if (media_video_frame->visible_rect().size() == wmp_natural_size &&
    (transform.rotation == media::VIDEO_ROTATION_90 ||
    transform.rotation == media::VIDEO_ROTATION_270)) {
    // Clear the transformation metadata to prevent double rotation during
    // paint
    media_video_frame->metadata().transformation = media::kNoTransformation;
    transform = media::kNoTransformation;
    }
    Ted (Chromium) Meyer . unresolved

    Should you just move this into condition on line 876?

    Vikram Pasupathy

    Good point, but `will_hard_flip` depends on checking the RasterContextProvider first. If I move this up, I'd have to drag all the GPU context setup up with it, which makes the code pretty messy. WDYT?

    Line 936, Patchset 2: if (!raster_context_provider) {

    if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) {
    raster_context_provider =
    wrapper->ContextProvider().RasterContextProvider();
    }
    }
    Ted (Chromium) Meyer . resolved

    This looks identical to line 885-889, is RasterContextProvider() expected to return null the first time and non-null after that?

    Vikram Pasupathy

    Removed the redundant check! Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ted (Chromium) Meyer
    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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
    Gerrit-Change-Number: 8008618
    Gerrit-PatchSet: 3
    Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
    Gerrit-Attention: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Jun 2026 23:18:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ted (Chromium) Meyer <tmath...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Ted (Chromium) Meyer (Gerrit)

    unread,
    Jun 26, 2026, 7:25:47 PM (2 days ago) Jun 26
    to Vikram Pasupathy, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
    Attention needed from Vikram Pasupathy

    Ted (Chromium) Meyer added 2 comments

    File third_party/blink/renderer/core/html/media/html_video_element.cc
    Line 899, Patchset 2: wmp_natural_size = wmp->NaturalSize();

    // The underlying VideoFrame may have been stripped of its transformation
    // metadata by the decoder or hardware buffer pipeline. If the frame lacks
    // a rotation but the WebMediaPlayer's pipeline metadata knows it exists,
    // we must inherit it.
    if (transform.rotation == media::VIDEO_ROTATION_0) {
    transform = wmp->GetVideoTransformation();
    media_video_frame->metadata().transformation = transform;
    }

    if (media_video_frame->visible_rect().size() == wmp_natural_size &&
    (transform.rotation == media::VIDEO_ROTATION_90 ||
    transform.rotation == media::VIDEO_ROTATION_270)) {
    // Clear the transformation metadata to prevent double rotation during
    // paint
    media_video_frame->metadata().transformation = media::kNoTransformation;
    transform = media::kNoTransformation;
    }
    Ted (Chromium) Meyer . unresolved

    Should you just move this into condition on line 876?

    Vikram Pasupathy

    Good point, but `will_hard_flip` depends on checking the RasterContextProvider first. If I move this up, I'd have to drag all the GPU context setup up with it, which makes the code pretty messy. WDYT?

    Ted (Chromium) Meyer

    I'm not sure I see the messy aspect? Wouldn't it just be moving line 886-892 up earlier? I guess it's an expensive setup that's pre-empted by the early return, but how often does that early return actually fire in real usage?

    Line 936, Patchset 2: if (!raster_context_provider) {
    if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) {
    raster_context_provider =
    wrapper->ContextProvider().RasterContextProvider();
    }
    }
    Ted (Chromium) Meyer . unresolved

    This looks identical to line 885-889, is RasterContextProvider() expected to return null the first time and non-null after that?

    Vikram Pasupathy

    Removed the redundant check! Done

    Ted (Chromium) Meyer

    Missing a patch set? This looks unchanged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vikram Pasupathy
    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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
    Gerrit-Change-Number: 8008618
    Gerrit-PatchSet: 3
    Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
    Gerrit-Attention: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Jun 2026 23:25:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ted (Chromium) Meyer <tmath...@chromium.org>
    Comment-In-Reply-To: Vikram Pasupathy <vpasu...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vikram Pasupathy (Gerrit)

    unread,
    Jun 26, 2026, 7:45:35 PM (2 days ago) Jun 26
    to Ted (Chromium) Meyer, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
    Attention needed from Ted (Chromium) Meyer

    Vikram Pasupathy added 2 comments

    File third_party/blink/renderer/core/html/media/html_video_element.cc
    Line 899, Patchset 2: wmp_natural_size = wmp->NaturalSize();

    // The underlying VideoFrame may have been stripped of its transformation
    // metadata by the decoder or hardware buffer pipeline. If the frame lacks
    // a rotation but the WebMediaPlayer's pipeline metadata knows it exists,
    // we must inherit it.
    if (transform.rotation == media::VIDEO_ROTATION_0) {
    transform = wmp->GetVideoTransformation();
    media_video_frame->metadata().transformation = transform;
    }

    if (media_video_frame->visible_rect().size() == wmp_natural_size &&
    (transform.rotation == media::VIDEO_ROTATION_90 ||
    transform.rotation == media::VIDEO_ROTATION_270)) {
    // Clear the transformation metadata to prevent double rotation during
    // paint
    media_video_frame->metadata().transformation = media::kNoTransformation;
    transform = media::kNoTransformation;
    }
    Ted (Chromium) Meyer . unresolved

    Should you just move this into condition on line 876?

    Vikram Pasupathy

    Good point, but `will_hard_flip` depends on checking the RasterContextProvider first. If I move this up, I'd have to drag all the GPU context setup up with it, which makes the code pretty messy. WDYT?

    Ted (Chromium) Meyer

    I'm not sure I see the messy aspect? Wouldn't it just be moving line 886-892 up earlier? I guess it's an expensive setup that's pre-empted by the early return, but how often does that early return actually fire in real usage?

    Vikram Pasupathy

    Like so?

    Line 936, Patchset 2: if (!raster_context_provider) {
    if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) {
    raster_context_provider =
    wrapper->ContextProvider().RasterContextProvider();
    }
    }
    Ted (Chromium) Meyer . unresolved

    This looks identical to line 885-889, is RasterContextProvider() expected to return null the first time and non-null after that?

    Vikram Pasupathy

    Removed the redundant check! Done

    Ted (Chromium) Meyer

    Missing a patch set? This looks unchanged

    Vikram Pasupathy

    oops. PTAL

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ted (Chromium) Meyer
    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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
    Gerrit-Change-Number: 8008618
    Gerrit-PatchSet: 4
    Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
    Gerrit-CC: srirama chandra sekhar <srir...@samsung.com>
    Gerrit-Attention: Ted (Chromium) Meyer <tmath...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Jun 2026 23:45:22 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Ted (Chromium) Meyer (Gerrit)

    unread,
    Jun 26, 2026, 8:05:47 PM (2 days ago) Jun 26
    to Vikram Pasupathy, Dirk Schulze, CJ DiMeglio, Stephen Chenney, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, srirama chandra sekhar, fserb...@chromium.org, blink-reviews-p...@chromium.org, fmalit...@chromium.org, drott+bl...@chromium.org, blink-re...@chromium.org, blink-revi...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, eric.c...@apple.com, erickun...@chromium.org, feature-me...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz+wa...@chromium.org
    Attention needed from Vikram Pasupathy

    Ted (Chromium) Meyer voted and added 2 comments

    Votes added by Ted (Chromium) Meyer

    Code-Review+1

    2 comments

    File third_party/blink/renderer/core/html/media/html_video_element.cc
    Line 899, Patchset 2: wmp_natural_size = wmp->NaturalSize();

    // The underlying VideoFrame may have been stripped of its transformation
    // metadata by the decoder or hardware buffer pipeline. If the frame lacks
    // a rotation but the WebMediaPlayer's pipeline metadata knows it exists,
    // we must inherit it.
    if (transform.rotation == media::VIDEO_ROTATION_0) {
    transform = wmp->GetVideoTransformation();
    media_video_frame->metadata().transformation = transform;
    }

    if (media_video_frame->visible_rect().size() == wmp_natural_size &&
    (transform.rotation == media::VIDEO_ROTATION_90 ||
    transform.rotation == media::VIDEO_ROTATION_270)) {
    // Clear the transformation metadata to prevent double rotation during
    // paint
    media_video_frame->metadata().transformation = media::kNoTransformation;
    transform = media::kNoTransformation;
    }
    Ted (Chromium) Meyer . resolved

    Should you just move this into condition on line 876?

    Vikram Pasupathy

    Good point, but `will_hard_flip` depends on checking the RasterContextProvider first. If I move this up, I'd have to drag all the GPU context setup up with it, which makes the code pretty messy. WDYT?

    Ted (Chromium) Meyer

    I'm not sure I see the messy aspect? Wouldn't it just be moving line 886-892 up earlier? I guess it's an expensive setup that's pre-empted by the early return, but how often does that early return actually fire in real usage?

    Vikram Pasupathy

    Like so?

    Ted (Chromium) Meyer

    it seems fine to me now.

    Line 936, Patchset 2: if (!raster_context_provider) {
    if (auto wrapper = SharedGpuContext::ContextProviderWrapper()) {
    raster_context_provider =
    wrapper->ContextProvider().RasterContextProvider();
    }
    }
    Ted (Chromium) Meyer . resolved

    This looks identical to line 885-889, is RasterContextProvider() expected to return null the first time and non-null after that?

    Vikram Pasupathy

    Removed the redundant check! Done

    Ted (Chromium) Meyer

    Missing a patch set? This looks unchanged

    Vikram Pasupathy

    oops. PTAL

    Ted (Chromium) Meyer

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vikram Pasupathy
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement 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: I3a3c314b9e919e57028e7b312930fa9e027ad84b
      Gerrit-Change-Number: 8008618
      Gerrit-PatchSet: 4
      Gerrit-Owner: Vikram Pasupathy <vpasu...@chromium.org>
      Gerrit-Reviewer: Ted (Chromium) Meyer <tmath...@chromium.org>
      Gerrit-Reviewer: Vikram Pasupathy <vpasu...@chromium.org>
      Gerrit-CC: CJ DiMeglio <lethala...@chromium.org>
      Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
      Gerrit-CC: Frank Liberato <libe...@chromium.org>
      Gerrit-CC: Stephen Chenney <sche...@chromium.org>
      Gerrit-Attention: Vikram Pasupathy <vpasu...@chromium.org>
      Gerrit-Comment-Date: Sat, 27 Jun 2026 00:05:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages