Giter Club home page Giter Club logo

Comments (2)

junov avatar junov commented on June 4, 2024

Setting width/height or attempting to read the bitmap of a detached OffscreenCanvas are programming errors IMHO. I am pretty sure throwing an InvalidState exception is the right thing to do in almost all cases.

For the placeholder situation, could you clarify what the problematic use case is? Setting the width or height on a placeholder canvas (i.e. after calling transferControlToOffscreen) is supposed to be a no-op. Spec'ed here: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-placeholder
As far as the spec is concerned, the placeholder canvas does not store a reference to the OffscreenCanvas that controls it (though implementations may have an internal reference that has no impact on API behavior). The only reference that is prescribed by the spec is in the other direction: the OffscreenCanvas has an optional weak reference to a placeholder canvas. The canvas element knows that it is being controlled by an offscreen canvas via its context mode, which may be set to placeholder, but it does not hold a reference to the actual OffscreenCanvas. There is no data flow from the placeholder to the OffscreenCanvas; data only flows in the other direction. This unidirectionality makes it trivial to ensure that the spec is free of signals that would be vulnerable to deadlocks or feedback loops.

from html.

Kaiido avatar Kaiido commented on June 4, 2024

Setting width/height or attempting to read the bitmap of a detached OffscreenCanvas are programming errors IMHO. I am pretty sure throwing an InvalidState exception is the right thing to do in almost all cases.

Agreed, I'll take it as a Chrome position and will try to prepare a PR to that effect when I get time.

For the placeholder situation, could you clarify what the problematic use case is?

I was only talking about the relation OffscreenCanvas => placeholder<canvas>. I simply noticed that the OffscreenCanvas's placeholder canvas element isn't unset in the transfer steps and since the width and height setters aren't defined (yet) for when context mode is detached what happens to the placeholder canvas is also unspecced.

But I now see that even the context mode: none has some small interop issues with placeholder canvases, and the specs seem unclear here too. See this fiddle where we can see that Safari does resize the placeholder canvas even when there is no context on the OffscreenCanvas, while Firefox will wait until the context is created and Chrome until there is actual drawings on the context. All the specs say is that commit() was supposed to be updating the placeholder size, which is going to be replaced by "update the rendering".

from html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.