Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
benkuper opened this issue Oct 17, 2024 · 0 comments
Open
1 task done

Comments

@benkuper
Copy link

benkuper commented Oct 17, 2024

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 ?

EDIT :
I think what would be interesting is that, either by default or as an option, in the juceToQuickJs and quickJsTojuce functions, there is a way to detect if the var is a DynamicObject pointer, and if it is, then check it already exists in the context, and if it does, only return its corresponding QuickJS / JUCE equivalent. This would avoid having to recursively convert everything all the 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

  • I agree to follow the Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant