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

Missing callback registry for browsers created without registered js objects #1335

Conversation

illfang
Copy link
Contributor

@illfang illfang commented Oct 14, 2015

Branch master, currently 7aa1287

I discovered this issue when investigating the erroneous execution of

await browser.EvaluateScriptAsync("document.getElementById('lst-ib').value = 'CefSharp Was Here!'");

in the CefSharp.OffScreen.Example
Since e9675a2

In this commit the execution of evaluated script will stop if no root object could be found as the evaluated script could create a callback during the SerializeV8Object(result, responseArgList, 2, callbackRegistry); call.

Browsers no object (sync & asnyc) has been registered will not hold a root object and therefore, no callback registry which would, prior to e9675a2, lead to an exception when the evaluted javascript source code would return a callback function.

This leads to the CefSharp.OffScreen.Example not executing properly. Of course, if the check for a missing root object would be removed the example would execute. However, callback functions could not be used.

Therefore, I think that a root object should be created even if no objects have been registered. The root object itself checks if a sync / async object exists and will therefore, only act as a manager for the callbacks which should not be too heavy.

else
{
auto rootObject = gcnew JavascriptRootObjectWrapper(browser->GetIdentifier(), browserWrapper->BrowserProcess);
rootObject->Bind(_javascriptRootObject, _javascriptAsyncRootObject, context->GetGlobal());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider moving the if (!Object::ReferenceEquals(_javascriptRootObject, nullptr) || !Object::ReferenceEquals(_javascriptAsyncRootObject, nullptr)) check here, so we don't bother calling bind or getting a context. And that's just a minor tweak 👍

@amaitland amaitland added this to the 45.0.0 milestone Oct 15, 2015
… bind the root object if objects are available
@illfang illfang force-pushed the fix-create-callback-registry-without-root-objects branch from c441497 to 91976cd Compare October 15, 2015 02:38
@illfang
Copy link
Contributor Author

illfang commented Oct 15, 2015

I'd consider moving the [...] check here, so we don't bother calling bind or getting a context.

Good point. I've adjusted the PR to avoid the access of the global object.

@amaitland
Copy link
Member

Good point. I've adjusted the PR to avoid the access of the global object.

Great, thanks 👍

amaitland added a commit that referenced this pull request Oct 15, 2015
…thout-root-objects

Missing callback registry for browsers created without registered js objects
@amaitland amaitland merged commit b9de2b0 into cefsharp:master Oct 15, 2015
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

Successfully merging this pull request may close these issues.

2 participants