How to use CefV8ArrayBuffer

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Re: How to use CefV8ArrayBuffer

Postby magreenblatt » Thu Aug 16, 2018 3:56 pm

johnh wrote:It's as if GC just gives , or at least whatever mechanism tries to call ReleaseBuffer.. :(
The only other way around this would be to have a fixed ArrayBuffer which exists for the duration of the application and just update it's contents.. but that would require exposing V8 GetContents() to modify the data on the native side.

Why can't you reuse a single ArrayBuffer created by the native code? Just keep a global reference on the JS side so it's not GC'd until the page unloads.

johnh wrote:which seems to lead directly back into V8 itself ?

Yes.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to use CefV8ArrayBuffer

Postby johnh » Thu Aug 16, 2018 4:05 pm

If I create an ArrayBuffer in JS.. I can pass a reference to that in as an argument to a native method, but how would I set it's data in the native code without re-creating it?
johnh
Techie
 
Posts: 44
Joined: Wed Aug 01, 2018 12:14 pm

Re: How to use CefV8ArrayBuffer

Postby magreenblatt » Thu Aug 16, 2018 4:10 pm

Use a bound method that returns an ArrayBuffer created by the native code. Like this, but returning an ArrayBuffer instead of a string: https://bitbucket.org/chromiumembedded/ ... -functions
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to use CefV8ArrayBuffer

Postby johnh » Thu Aug 16, 2018 4:14 pm

Yep, I'm already doing that in the Execute handler, the native code creates an ArrayBuffer .. keeps a reference to it and return it to JS.. now later on another native code function needs to execute to fill that buffer with new data, thats where I'm stuck, I can't find anyway to access the data of the ArrayBuffer in the native code.
johnh
Techie
 
Posts: 44
Joined: Wed Aug 01, 2018 12:14 pm

Re: How to use CefV8ArrayBuffer

Postby magreenblatt » Thu Aug 16, 2018 4:20 pm

Your native code needs to keep track of the native buffer that it used to create the ArrayBuffer.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to use CefV8ArrayBuffer

Postby johnh » Thu Aug 16, 2018 4:46 pm

Implemented, working like a charm and no memory leaking! :)

Thanks a million!
johnh
Techie
 
Posts: 44
Joined: Wed Aug 01, 2018 12:14 pm

Previous

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 55 guests