Skip to content

contextBridge doesn't clone VideoFrame. #46901

Closed

Description

@reitowo

Preflight Checklist

Electron Version

37.0.0

What operating system(s) are you using?

Windows

Operating System Version

Windows 11

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

contextBridge should clone Cloneable types listed in the documents https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, e.g. VideoFrame

Actual Behavior

It doesn't, and consider it a PlainObject, we can only get a plain object {}

Testcase Gist URL

https://gist.github.com/reitowo/333c280a9900cdcc84db01e1d962ce58

Image

Additional Information

No response

Activity

  1. added theissue type on May 2, 2025
  2. changed the title [-]contextBridge doesn't clone Cloneable types.[/-] [+]`contextBridge` doesn't clone Cloneable types.[/+] on May 2, 2025
  3. moved this to 👀 Unsorted Items in 37-x-yon May 2, 2025
  4. reitowo commented on May 2, 2025

    @reitowo
    MemberAuthor

    Add this will fix VideoFrame for me temporarily, but this seems not a decent "clone"

        auto* video_frame =
            blink::V8VideoFrame::ToWrappable(source_context->GetIsolate(), value);
        if (video_frame != nullptr) {
          auto* script_state = blink::ScriptState::ForCurrentRealm(
              destination_context->GetIsolate());
          return v8::MaybeLocal<v8::Value>(
              blink::ToV8Traits<blink::VideoFrame>::ToV8(script_state,
                                                         video_frame));
        }
    
  5. codebytere commented on May 2, 2025

    @codebytere
    Member

    @reitowo there are a few edge cases here - we don't support all cloneable types listed there (some on a case by case basis, like WebBlob)

    cc @MarshallOfSound for thoughts on this one

  6. added
    status/confirmed
    and removed on May 2, 2025
  7. reitowo commented on May 2, 2025

    @reitowo
    MemberAuthor

    Alright then, is it possible for me to add support about VideoFrame? (Prepare for #46811)

    Is there a rule about the definition of "cloning"? For VideoFrame, there's a clone and close method. We can choose to 1) clone and close the original object, 2) we can just call clone, 3) we can just pass the original pointer to dest context.

  8. nikwen commented on May 2, 2025

    @nikwen
    Member

    Related: #46863

  9. reitowo commented on May 7, 2025

    @reitowo
    MemberAuthor

    I don't go through that deep detail, but I got a question, is it possible to reuse some web standard (chromium code) to "transfer"?

    Currently, WebBlob is just creating a new v8 object in new context referencing same object, which seems a problem. VideoFrame is also reusing this pattern instead of closing the old one and start a new one.

    However, passing objects between "contextBridge" seems not identical to "transfer", because transfer requires API to work with.

  10. changed the issue type fromtoon May 7, 2025
  11. changed the title [-]`contextBridge` doesn't clone Cloneable types.[/-] [+]`contextBridge` doesn't clone VideoFrame.[/+] on May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    37-x-ycomponent/context-bridgeenhancement ✨platform/allstatus/confirmed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions