Implement XRMediaBinding and media layers [chromium/src : main]

0 views
Skip to first unread message

Yong Li (xWF) (Gerrit)

unread,
May 21, 2026, 10:33:34 AM (12 days ago) May 21
to chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org

Yong Li (xWF) added 1 comment

File media/renderers/paint_canvas_video_renderer.cc
Line 1731, Patchset 7: const void* pixels = video_frame->data(VideoFrame::kARGB);
Yong Li (xWF) . resolved

Please fix this WARNING reported by autoreview issue finding: If `use_visible_rect` is true and the frame's visible rect is cropped, `video_frame->data(VideoFrame::kARGB)` will read from the un-offset origin of the coded data instead of the visible rect's origin.

You should conditionally use `video_frame->visible_data(VideoFrame::kARGB)` when `use_visible_rect` is true. Similarly, compute the dimensions for `SkImageInfo` using `use_visible_rect ? video_frame->visible_rect() : gfx::Rect(video_frame->coded_size())` like it's done elsewhere in this file.

Open in Gerrit

Related details

Attention set is empty
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: I32ca0be6c8fff3eb614ac9a8fa051a6e47cb9ef0
Gerrit-Change-Number: 7841399
Gerrit-PatchSet: 8
Gerrit-Owner: Yong Li (xWF) <yyon...@google.com>
Gerrit-CC: CJ DiMeglio <lethala...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Frank Liberato <libe...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Comment-Date: Thu, 21 May 2026 14:33:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Cooper (Gerrit)

unread,
May 26, 2026, 7:25:06 PM (7 days ago) May 26
to Yong Li (xWF), Brandon Jones, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Brandon Jones and Yong Li (xWF)

Alexander Cooper added 17 comments

Commit Message
Line 7, Patchset 14 (Latest):Implement XRMediaBinding and media layers
Alexander Cooper . unresolved

More of a description about how we're implementing it would be good.

File device/vr/openxr/android/openxr_graphics_binding_open_gles.cc
Line 281, Patchset 14 (Latest): gpu::SHARED_IMAGE_USAGE_RASTER_WRITE;
Alexander Cooper . unresolved

Raster read/write probably worth commenting? Or at least explaining here in CR

File third_party/blink/renderer/modules/xr/DEPS
Line 25, Patchset 14 (Latest): "+ui/gfx/gpu_fence.h",
Alexander Cooper . unresolved

I don't think this is used anymore?

File third_party/blink/renderer/modules/xr/xr_composition_layer.h
Line 24, Patchset 14 (Latest): XRCompositionLayer(XRSession* session,
XRGraphicsBinding* binding,
Alexander Cooper . unresolved

I won't make you split this out now, but a lot of the size/files of this CL are due to this change. In the future, if you identify a small but viral change like this as being necessary, a prep-CL to do that conversion with the existing types would be ideal to separate out.

File third_party/blink/renderer/modules/xr/xr_media_binding.cc
Line 102, Patchset 14 (Latest): nullptr, drawing_context);
Alexander Cooper . unresolved
File third_party/blink/renderer/modules/xr/xr_media_drawing_context.cc
Line 42, Patchset 14 (Latest): uint16_t w = video_->videoWidth();
uint16_t h = video_->videoHeight();
Alexander Cooper . unresolved

Chromium style generally frowns on this kind of name shortening, please use `width` and `height` instead of `w` and `h`.

Line 45, Patchset 14 (Latest): double scale = std::min(static_cast<double>(max_texture_size_) / w,
static_cast<double>(max_texture_size_) / h);
width_ = std::max(base::checked_cast<uint16_t>(1),
base::checked_cast<uint16_t>(w * scale));
height_ = std::max(base::checked_cast<uint16_t>(1),
Alexander Cooper . unresolved

I think max_texture_size_ *must* be greater than 0 here; so therefore w, h, and scale all have to be as well. `checked_cast` will CHECK/crash in the event of an overflow, not return 0, so the std::max's are not necessary..

Line 70, Patchset 14 (Latest): if (auto* wmp = video_->GetWebMediaPlayer()) {
Alexander Cooper . unresolved

See earlier comment re: name shortenings, `player` would be acceptable here though.

Line 75, Patchset 14 (Latest): if (!media_video_frame) {
return;
}
Alexander Cooper . unresolved

The presence of this check means that I think you can just turn 70 into an early return as well, and then you don't have to default initialize the two values in it's if block. If you can't get a media player, you'll always early return here. (Though obviously still need to check here).

Line 84, Patchset 14 (Latest): gpu::raster::RasterInterface* ri =
Alexander Cooper . unresolved

Can't shorten names.

Line 103, Patchset 14 (Latest): // This 2-copy solution is the best we can do for now without a big
Alexander Cooper . unresolved

😮

Line 143, Patchset 14 (Latest):
// Flush the commands to ensure the GPU executes the copy before OpenXR
// consumes it.
ri->Flush();
Alexander Cooper . unresolved

I *think* plumbing the sync tokens down would do the same thing and wouldn't introduce a potential sync action here that can hang things.

File third_party/blink/renderer/modules/xr/xr_session.h
Line 204, Patchset 14 (Latest):
XRGraphicsBinding* GetGraphicsBinding() const {
if (graphics_bindings_.empty()) {
return nullptr;
}
return graphics_bindings_.begin()->Get();
}
Alexander Cooper . unresolved

Doesn't seem to be used anymore. Further, something like this isn't really right either.

File third_party/blink/renderer/modules/xr/xr_webgl_binding.cc
Line 289, Patchset 14 (Latest): if (!init->hasWidth()) {
exception_state.ThrowTypeError("width is required.");
return nullptr;
}
if (!init->hasHeight()) {
exception_state.ThrowTypeError("height is required.");
return nullptr;
}
Alexander Cooper . unresolved

Can be removed like the other items since `Validate` should check this now?

Edit: Actually, it doesn't look like validate checks that width/height exist, which feels like it should do so.

Line 333, Patchset 14 (Latest): if (!ValidateCylinderLayerInit(init, exception_state)) {
Alexander Cooper . unresolved

This doesn't validate that the required items are set.

Line 494, Patchset 14 (Latest): auto* drawing_context = layer->drawing_context();
if (!drawing_context || !drawing_context->IsWebGL()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
"Layer drawing context is not WebGL.");
return nullptr;
}
auto* webgl_context = static_cast<XRWebGLDrawingContext*>(drawing_context);
Alexander Cooper . unresolved

So, the only way this would trigger is if we try to call this method with a Media Layer. I *think* an internal bool on the layer indicating that it's a media layer would *maybe* be cleaner, and we can assert that if it is *not* a media layer, it should have a WebGL drawing context. I *think* that may feel like a cleaner interface to me than an `IsWebGL` boolean, but open to discussion.

Separately, @baj...@chromium.org, should the spec be modified to throw if you try to call this for a media layer always anyway?

File third_party/blink/renderer/platform/runtime_enabled_features.json5
Line 6929, Patchset 14 (Latest): status: "stable",
Alexander Cooper . unresolved

Shouldn't be stable yet; should leave it as experimental until we can do a chromestatus for it.

Open in Gerrit

Related details

Attention is currently required from:
  • Brandon Jones
  • Yong Li (xWF)
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: I32ca0be6c8fff3eb614ac9a8fa051a6e47cb9ef0
    Gerrit-Change-Number: 7841399
    Gerrit-PatchSet: 14
    Gerrit-Owner: Yong Li (xWF) <yyon...@google.com>
    Gerrit-Reviewer: Alexander Cooper <alco...@chromium.org>
    Gerrit-Reviewer: Brandon Jones <baj...@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: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Yong Li (xWF) <yyon...@google.com>
    Gerrit-Attention: Brandon Jones <baj...@chromium.org>
    Gerrit-Comment-Date: Tue, 26 May 2026 23:24:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Brandon Jones (Gerrit)

    unread,
    May 28, 2026, 2:39:49 PM (5 days ago) May 28
    to Yong Li (xWF), Alexander Cooper, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Yong Li (xWF)

    Brandon Jones added 5 comments

    File device/vr/openxr/android/openxr_graphics_binding_open_gles.cc
    Line 281, Patchset 14 (Latest): gpu::SHARED_IMAGE_USAGE_RASTER_WRITE;
    Alexander Cooper . unresolved

    Raster read/write probably worth commenting? Or at least explaining here in CR

    Brandon Jones

    Does this have any performance implications for non-media layers? If so, or if we're not certain, is there a way we can apply these usages only to the images created for media layers?

    File third_party/blink/renderer/modules/xr/xr_media_drawing_context.cc
    Line 103, Patchset 14 (Latest): // This 2-copy solution is the best we can do for now without a big
    Alexander Cooper . unresolved

    😮

    Brandon Jones

    This made me 😮 too, but looking through the rest of the code I believe this path should only kick in when the video is larger than the max texture size? (Which... I'm somewhat skeptical that could even happen normally?) In fact, I'm tempted to say that we should consider adding validation to the spec that rejects in that case, but that's for a later discussion.

    In any case, the large texture size will make this brutally slow BUT you're also already pushing the limits of what most GPUs will handle at that point, so you're in for a bad time whether or not this scaling needs to take place.

    I would recommend adding something to the comment to explain that this path should only kick in in extreme circumstances.

    File third_party/blink/renderer/modules/xr/xr_session.h
    Line 204, Patchset 14 (Latest):
    XRGraphicsBinding* GetGraphicsBinding() const {
    if (graphics_bindings_.empty()) {
    return nullptr;
    }
    return graphics_bindings_.begin()->Get();
    }
    Alexander Cooper . unresolved

    Doesn't seem to be used anymore. Further, something like this isn't really right either.

    Brandon Jones

    Agreed. It's not clear under which circumstances it would be useful to know whatever the first registered graphics binding is.

    File third_party/blink/renderer/modules/xr/xr_webgl_binding.cc
    Line 494, Patchset 14 (Latest): auto* drawing_context = layer->drawing_context();
    if (!drawing_context || !drawing_context->IsWebGL()) {
    exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
    "Layer drawing context is not WebGL.");
    return nullptr;
    }
    auto* webgl_context = static_cast<XRWebGLDrawingContext*>(drawing_context);
    Alexander Cooper . unresolved

    So, the only way this would trigger is if we try to call this method with a Media Layer. I *think* an internal bool on the layer indicating that it's a media layer would *maybe* be cleaner, and we can assert that if it is *not* a media layer, it should have a WebGL drawing context. I *think* that may feel like a cleaner interface to me than an `IsWebGL` boolean, but open to discussion.

    Separately, @baj...@chromium.org, should the spec be modified to throw if you try to call this for a media layer always anyway?

    Brandon Jones

    We absolutely should have something in the spec that throws here. That kind of fits the discussion in https://github.com/immersive-web/layers/issues/326 but we didn't consider media layers as part of it.

    In any case, sounds like the intent is that we will start throwing if `get{View}SubImage()` is called on anything that wasn't created by the same binding, regardless of if it's a media or WebGL layer. Ideally that can be implemented here to simplify the logic?

    Line 566, Patchset 14 (Latest): return nullptr;
    Brandon Jones . unresolved

    Ditto the conversation above here.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Yong Li (xWF)
    Gerrit-Comment-Date: Thu, 28 May 2026 18:39:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Alexander Cooper <alco...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alexander Cooper (Gerrit)

    unread,
    May 28, 2026, 3:47:24 PM (5 days ago) May 28
    to Yong Li (xWF), Brandon Jones, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Yong Li (xWF)

    Alexander Cooper added 1 comment

    File third_party/blink/renderer/modules/xr/xr_webgl_binding.cc
    Line 494, Patchset 14 (Latest): auto* drawing_context = layer->drawing_context();
    if (!drawing_context || !drawing_context->IsWebGL()) {
    exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
    "Layer drawing context is not WebGL.");
    return nullptr;
    }
    auto* webgl_context = static_cast<XRWebGLDrawingContext*>(drawing_context);
    Alexander Cooper . unresolved

    So, the only way this would trigger is if we try to call this method with a Media Layer. I *think* an internal bool on the layer indicating that it's a media layer would *maybe* be cleaner, and we can assert that if it is *not* a media layer, it should have a WebGL drawing context. I *think* that may feel like a cleaner interface to me than an `IsWebGL` boolean, but open to discussion.

    Separately, @baj...@chromium.org, should the spec be modified to throw if you try to call this for a media layer always anyway?

    Brandon Jones

    We absolutely should have something in the spec that throws here. That kind of fits the discussion in https://github.com/immersive-web/layers/issues/326 but we didn't consider media layers as part of it.

    In any case, sounds like the intent is that we will start throwing if `get{View}SubImage()` is called on anything that wasn't created by the same binding, regardless of if it's a media or WebGL layer. Ideally that can be implemented here to simplify the logic?

    Alexander Cooper

    but we didn't consider media layers as part of it.

    I think they're implicitly covered, because they're created by an XrMediaBinding and *not* the XrWebGlBinding or XrGpuBinding, so they'd throw if passed into here, because this binding didn't create them. Even with Yong's current logic of the `binding()` member of the Media layers being nullptr, I think a trivial `if (layer->binding() != this)` would satisfy the proposed spec change and make our guarantees here.

    Gerrit-Comment-Date: Thu, 28 May 2026 19:47:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Brandon Jones <baj...@chromium.org>
    Comment-In-Reply-To: Alexander Cooper <alco...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Yong Li (xWF) (Gerrit)

    unread,
    Jun 1, 2026, 2:27:18 PM (yesterday) Jun 1
    to Alexander Cooper, Brandon Jones, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Alexander Cooper and Brandon Jones

    Yong Li (xWF) added 3 comments

    File device/vr/openxr/android/openxr_graphics_binding_open_gles.cc
    Line 281, Patchset 14 (Latest): gpu::SHARED_IMAGE_USAGE_RASTER_WRITE;
    Alexander Cooper . unresolved

    Raster read/write probably worth commenting? Or at least explaining here in CR

    Brandon Jones

    Does this have any performance implications for non-media layers? If so, or if we're not certain, is there a way we can apply these usages only to the images created for media layers?

    Yong Li (xWF)

    @Alex, yes we need them for using CopyVideoFrameToSharedImage. @Brandon, yeah, I am going to add a boolean in mojom struct to indicate if we need raster access

    File third_party/blink/renderer/modules/xr/xr_media_drawing_context.cc
    Line 103, Patchset 14 (Latest): // This 2-copy solution is the best we can do for now without a big
    Alexander Cooper . unresolved

    😮

    Brandon Jones

    This made me 😮 too, but looking through the rest of the code I believe this path should only kick in when the video is larger than the max texture size? (Which... I'm somewhat skeptical that could even happen normally?) In fact, I'm tempted to say that we should consider adding validation to the spec that rejects in that case, but that's for a later discussion.

    In any case, the large texture size will make this brutally slow BUT you're also already pushing the limits of what most GPUs will handle at that point, so you're in for a bad time whether or not this scaling needs to take place.

    I would recommend adding something to the comment to explain that this path should only kick in in extreme circumstances.

    Yong Li (xWF)

    Yeah, there is no good solution for now in such a case. Will add more comments

    File third_party/blink/renderer/modules/xr/xr_webgl_binding.cc
    Line 494, Patchset 14 (Latest): auto* drawing_context = layer->drawing_context();
    if (!drawing_context || !drawing_context->IsWebGL()) {
    exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
    "Layer drawing context is not WebGL.");
    return nullptr;
    }
    auto* webgl_context = static_cast<XRWebGLDrawingContext*>(drawing_context);
    Alexander Cooper . unresolved

    So, the only way this would trigger is if we try to call this method with a Media Layer. I *think* an internal bool on the layer indicating that it's a media layer would *maybe* be cleaner, and we can assert that if it is *not* a media layer, it should have a WebGL drawing context. I *think* that may feel like a cleaner interface to me than an `IsWebGL` boolean, but open to discussion.

    Separately, @baj...@chromium.org, should the spec be modified to throw if you try to call this for a media layer always anyway?

    Brandon Jones

    We absolutely should have something in the spec that throws here. That kind of fits the discussion in https://github.com/immersive-web/layers/issues/326 but we didn't consider media layers as part of it.

    In any case, sounds like the intent is that we will start throwing if `get{View}SubImage()` is called on anything that wasn't created by the same binding, regardless of if it's a media or WebGL layer. Ideally that can be implemented here to simplify the logic?

    Alexander Cooper

    but we didn't consider media layers as part of it.

    I think they're implicitly covered, because they're created by an XrMediaBinding and *not* the XrWebGlBinding or XrGpuBinding, so they'd throw if passed into here, because this binding didn't create them. Even with Yong's current logic of the `binding()` member of the Media layers being nullptr, I think a trivial `if (layer->binding() != this)` would satisfy the proposed spec change and make our guarantees here.

    Yong Li (xWF)

    I remember the spec does allow using layers with different (GL) bindings. We fixed a problem like that, because the samples do use one binding to create layers and use another binding to render them.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alexander Cooper
    • Brandon Jones
    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: I32ca0be6c8fff3eb614ac9a8fa051a6e47cb9ef0
    Gerrit-Change-Number: 7841399
    Gerrit-PatchSet: 14
    Gerrit-Owner: Yong Li (xWF) <yyon...@google.com>
    Gerrit-Reviewer: Alexander Cooper <alco...@chromium.org>
    Gerrit-Reviewer: Brandon Jones <baj...@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: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Brandon Jones <baj...@chromium.org>
    Gerrit-Attention: Alexander Cooper <alco...@chromium.org>
    Gerrit-Comment-Date: Mon, 01 Jun 2026 18:27:11 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Yong Li (xWF) (Gerrit)

    unread,
    Jun 1, 2026, 2:41:18 PM (yesterday) Jun 1
    to Alexander Cooper, Brandon Jones, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Alexander Cooper and Brandon Jones

    Yong Li (xWF) added 2 comments

    File device/vr/openxr/android/openxr_graphics_binding_open_gles.cc
    Line 281, Patchset 14 (Latest): gpu::SHARED_IMAGE_USAGE_RASTER_WRITE;
    Alexander Cooper . resolved

    Raster read/write probably worth commenting? Or at least explaining here in CR

    Brandon Jones

    Does this have any performance implications for non-media layers? If so, or if we're not certain, is there a way we can apply these usages only to the images created for media layers?

    Yong Li (xWF)

    @Alex, yes we need them for using CopyVideoFrameToSharedImage. @Brandon, yeah, I am going to add a boolean in mojom struct to indicate if we need raster access

    Yong Li (xWF)

    Done

    File third_party/blink/renderer/modules/xr/xr_media_drawing_context.cc
    Line 103, Patchset 14 (Latest): // This 2-copy solution is the best we can do for now without a big
    Alexander Cooper . unresolved

    😮

    Brandon Jones

    This made me 😮 too, but looking through the rest of the code I believe this path should only kick in when the video is larger than the max texture size? (Which... I'm somewhat skeptical that could even happen normally?) In fact, I'm tempted to say that we should consider adding validation to the spec that rejects in that case, but that's for a later discussion.

    In any case, the large texture size will make this brutally slow BUT you're also already pushing the limits of what most GPUs will handle at that point, so you're in for a bad time whether or not this scaling needs to take place.

    I would recommend adding something to the comment to explain that this path should only kick in in extreme circumstances.

    Yong Li (xWF)

    Yeah, there is no good solution for now in such a case. Will add more comments

    Yong Li (xWF)

    BTW, in reality, the limit is usually 8192

    Gerrit-Comment-Date: Mon, 01 Jun 2026 18:41:09 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Yong Li (xWF) <yyon...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alexander Cooper (Gerrit)

    unread,
    Jun 1, 2026, 2:59:32 PM (yesterday) Jun 1
    to Yong Li (xWF), Brandon Jones, chromium...@chromium.org, Dirk Schulze, Kentaro Hara, Raphael Kubo da Costa, CJ DiMeglio, Stephen Chenney, blink-revie...@chromium.org, blink-reviews-p...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, feature-me...@chromium.org, feature-v...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
    Attention needed from Brandon Jones and Yong Li (xWF)

    Alexander Cooper added 1 comment

    File third_party/blink/renderer/modules/xr/xr_webgl_binding.cc
    Line 494, Patchset 14 (Latest): auto* drawing_context = layer->drawing_context();
    if (!drawing_context || !drawing_context->IsWebGL()) {
    exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
    "Layer drawing context is not WebGL.");
    return nullptr;
    }
    auto* webgl_context = static_cast<XRWebGLDrawingContext*>(drawing_context);
    Alexander Cooper . unresolved

    So, the only way this would trigger is if we try to call this method with a Media Layer. I *think* an internal bool on the layer indicating that it's a media layer would *maybe* be cleaner, and we can assert that if it is *not* a media layer, it should have a WebGL drawing context. I *think* that may feel like a cleaner interface to me than an `IsWebGL` boolean, but open to discussion.

    Separately, @baj...@chromium.org, should the spec be modified to throw if you try to call this for a media layer always anyway?

    Brandon Jones

    We absolutely should have something in the spec that throws here. That kind of fits the discussion in https://github.com/immersive-web/layers/issues/326 but we didn't consider media layers as part of it.

    In any case, sounds like the intent is that we will start throwing if `get{View}SubImage()` is called on anything that wasn't created by the same binding, regardless of if it's a media or WebGL layer. Ideally that can be implemented here to simplify the logic?

    Alexander Cooper

    but we didn't consider media layers as part of it.

    I think they're implicitly covered, because they're created by an XrMediaBinding and *not* the XrWebGlBinding or XrGpuBinding, so they'd throw if passed into here, because this binding didn't create them. Even with Yong's current logic of the `binding()` member of the Media layers being nullptr, I think a trivial `if (layer->binding() != this)` would satisfy the proposed spec change and make our guarantees here.

    Yong Li (xWF)

    I remember the spec does allow using layers with different (GL) bindings. We fixed a problem like that, because the samples do use one binding to create layers and use another binding to render them.

    Alexander Cooper

    Hmm, that's a potential wrinkle for us making that spec change; but I think overall we should be in the clear to not allow getting the texture for a media layer, given that the long term intention is DRM and that if you wanted to do anything with the texture you should just not use MediaLayers to begin with.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Brandon Jones
    • Yong Li (xWF)
    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: I32ca0be6c8fff3eb614ac9a8fa051a6e47cb9ef0
    Gerrit-Change-Number: 7841399
    Gerrit-PatchSet: 14
    Gerrit-Owner: Yong Li (xWF) <yyon...@google.com>
    Gerrit-Reviewer: Alexander Cooper <alco...@chromium.org>
    Gerrit-Reviewer: Brandon Jones <baj...@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: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-CC: Stephen Chenney <sche...@chromium.org>
    Gerrit-Attention: Yong Li (xWF) <yyon...@google.com>
    Gerrit-Attention: Brandon Jones <baj...@chromium.org>
    Gerrit-Comment-Date: Mon, 01 Jun 2026 18:59:19 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages