(To be clear I don't think this is very important, but I wrote a test case so I wanted to share it here - maybe someday it will matter enough to someone to iron out.)
transferToImageBitmap() can be called on OffscreenCanvases which are actually on-screen via transferControlToOffscreen(). Thus the compositor and transferToImageBitmap() can both try to take frames from the canvas.
Here's a sample page: https://codepen.io/kainino0x/pen/dyxoNRd
It raises issues like:
- It's probably not tested that
preserveDrawingBuffer doesn't apply to transferToImageBitmap (chrome gets this wrong)
- It's unclear what should happen when calling
transferToImageBitmap on a canvas that has preserveDrawingBuffer: false after it has been presented (get the presented canvas's contents? get nothing and clear the presented canvas? get nothing but leave up the presented canvas?)
- Should
transferToImageBitmap() really work at all with transferControlToOffscreen()? Would be curious to see if any websites do that.
BTW in various browsers some of the canvas images will eventually "expire" if left in the background for long enough, which AFAIU is intended to be allowed with preserveDrawingBuffer: false but maybe not otherwise.
See also #3612, #3615