Remove refs from WebRenderContext constructor API#153
Conversation
Specifically, the lifetime of WebRenderContext is changed to not depend on lifetimes of CanvasRenderingContext2d and Window objects, since these lifetimes don't actually enforce the existence of web resources anyways. The mut is also removed from CanvasRenderingContext2d since its API has no mut calls and this generally makes the WebRenderContext difficult to use in libraries like druid. For compatibility the WebRenderContext maintains a phantom lifetime placeholder for compatibility as well as for anticipating a correct lifetime there.
|
I'm really not sure who 'owns' this code, I've never looked at the piet-web stuff. Are you using this anywhere @elrnv? |
|
I was looking for a UI library to do some prototyping preferably with web support, since it makes it easier to share the results with others. I saw that druid doesn't yet have complete support for wasm so I thought I could contribute there. This PR makes it possible to integrate piet with wasm in druid (#759). Hope it helps :) |
|
So I think the motivation for having these signatures might be So I guess: can you run tests in piet-common? I think it doesn't quite matter how closely these APIs match, as long as they are used correctly from the particular backends; it does matter when we want to be able to treat the backends interchangeably. |
|
The |
|
Can confirm the compile test in If I remember correctly (from reading through the code and issues), the goal of having a lifetime on the I'm not sure how to tie the lifetime to the availability of the context in wasm. Getting the window initially is done through I'm not sure how to test the situation where the window/canvas/context would not be available. I tried deleting the canvas from the inspector, but it did not cause any errors, as if the underlying canvas/context were not garbage collected. |
Specifically, the lifetime of
WebRenderContextis changed to not depend on lifetimes ofCanvasRenderingContext2dandWindowobjects, since these lifetimes don't actually enforce the existence of web resources anyways.The
mutis also removed fromCanvasRenderingContext2dsince its API has nomutcalls and this generally makes theWebRenderContextdifficult to use in libraries like druid.For compatibility the
WebRenderContextmaintains a phantom lifetime placeholder for compatibility as well as for anticipating a correct lifetime there.