feat: Create Frame.withBaseClass
to ensure it's always a FrameHostObject
#2849
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Adds the
Frame.withBaseClass(..)
method, which takes ajsi::Object
and uses the givenjsi::Object
as it's new base class.Before, there were two approaches for combining objects in JS:
frame
andcanvas
and copies them here, even if you don't use them.Proxy
:Unfortunately both of these approaches have a common problem; the
drawableFrame
value is no longer aFrameHostObject
/jsi::HostObject
, but instead a conventionaljsi::Object
now. It will also no longer hold the nativeshared_ptr
of buffer data.This causes two issues:
drawableFrame
cannot be passed to native Frame Processor Plugins, because those expect aFrameHostObject
, not a normaljsi::Object
. That should've thrown an error actually, maybe in some runtimes it was swallowed? Not sureuseFrameProcessor
context (e.g.runAsync
) wouldn't work anymore, as thedrawableFrame
is not a HostObject that can be easily shared. Instead, it was a conventionaljsi::Object
that had to be deep-copied.So instead, we need to make sure that the
frame
stays the instance it currently is, and we do that by adding a new method toFrameHostObject
:withBaseClass
.This basically just uses the object it receives and sets it as a class property, and all properties that do not exist on
FrameHostObject
will now be looked up on the newjsi::Object
base class.This means that the code is now:
..and
drawableFrame
is now still aFrameHostObject
- so it can be passed to Frame Processor Plugins without an issue. AlsorunAsync
should now work fine.Changes
Tested on
Related issues
runAsync
inuseSkiaFrameProcessor
runs only once #2842