JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

[Question] [Javascript] Returning already-converted JS reference from C function call

Open benkuper opened this issue 4 months ago • 0 comments

Detailed steps on how to reproduce the bug

I wish I could post a PR for this, but I don't know where to start, so this is more of a question about how to handle this :

My software creates a potentially big hierarchy of nested DynamicObject (can go more than 10k). this hierarchy is passed to the JS engine via registerNativeObject, this can be a bit long to convert (JucetoQuickJs function) but it's manageable when it's only on script init.

Those objects have C-Function methods that return other parts of the hierarchy, like getParent(levelToSearch), getChild(nameOfTheChild), getSpecificTypeOfChildren(type), etc.

My problem is that when I call one of those methods, the returned object is fully converted (JuceToQuickJS) during function return, even though the returned object already has been converted and exists in the hierarchy. This result in a very slow processing time because those returned objects can be big as they get near top-level of the hierarchy.

I don't know how the previous engine was dealing with this, but it was definitely not having the same conversion time, or not even doing conversions.

So my question is : is there a way to return a reference of already converted JS-objects instead of having to reconvert a new object each time ?

Thank you

What is the expected behaviour?

It would be great that the engine detects that this object already has been registered , then it passes its reference instead of manually converting everything everytime.

Operating systems

Windows

What versions of the operating systems?

11

Architectures

64-bit

Stacktrace

No response

Plug-in formats (if applicable)

No response

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • [X] I agree to follow the Code of Conduct

benkuper avatar Oct 17 '24 21:10 benkuper