Problem with CreateArrayBuffer

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.

Problem with CreateArrayBuffer

Postby nadkoszulek » Mon Jun 14, 2021 1:17 am

Hello,
I want to create and send large object to JS part application. And I have few problems with this.
Firstly, I can't create ArrayBuffer with CefV8Value::CreateArrayBuffer. I don't know why but when I use this method in rendered process in function OnContextCreated everything looks fine but I execute the same code in function
OnProcessMessageReceived my application crashed...

Code: Select all
class ReleaseCallback : public CefV8ArrayBufferReleaseCallback {
public:
    void ReleaseBuffer(void* buffer) override {
        MessageBox(0, L"Rele", L"MessageBox caption", MB_OK);
        std::free(buffer);
    }
    IMPLEMENT_REFCOUNTING(ReleaseCallback);
};

Code: Select all
    void OnContextCreated(CefRefPtr<CefBrowser> browser,
                          CefRefPtr<CefFrame> frame,
                          CefRefPtr<CefV8Context> context) OVERRIDE {

        CefRefPtr<CefV8ArrayBufferReleaseCallback> callback = new ReleaseCallback();
        BYTE* pBuf = new (std::nothrow) BYTE[4342];
        auto obj = CefV8Value::CreateArrayBuffer(pBuf, 4342, callback);
        message_router_->OnContextCreated(browser, frame, context);
    }

Code: Select all
    bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
                                  CefRefPtr<CefFrame> frame,
                                  CefProcessId source_process,
                                  CefRefPtr<CefProcessMessage> message) OVERRIDE {
        CefRefPtr<CefV8ArrayBufferReleaseCallback> callback = new ReleaseCallback();
        BYTE* pBuf = new (std::nothrow) BYTE[4342];
        auto obj = CefV8Value::CreateArrayBuffer(pBuf, 4342, callback);
        return message_router_->OnProcessMessageReceived(browser, frame,
                                                         source_process, message);
    }


What am I doing wrong? Or there is other method to create array buffer? As I know CefV8Value::CreateArrayBuffer can be used only in rendered process. Is possible to create and send arrayBuffer in browser process? For example with CefFrame::ExecuteJavaScript?
nadkoszulek
Newbie
 
Posts: 1
Joined: Sun Jun 13, 2021 5:39 am

Re: Problem with CreateArrayBuffer

Postby magreenblatt » Mon Jun 14, 2021 10:38 am

You're doing many things wrong. I suggest reading the docs.
magreenblatt
Site Admin
 
Posts: 10947
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 15 guests