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

Make JS bindings work with subprocesses hosting multiple browser instances #1562

Closed

Conversation

cefsharp-ms
Copy link
Contributor

When the popup functionality is used, more than one browser instance can be hosted in the same subprocess. As the bound JS objects are not stored on a per-browser basis they won't work properly in this scenario. I modified the storage and binding mechanism a bit to solve this.


static JavascriptRootObject^ Update(int key, JavascriptRootObject^ value)
Copy link
Member

Choose a reason for hiding this comment

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

Where is this method used?

@amaitland
Copy link
Member

@cefsharp-ms Are you able to add a test case to one of the examples?

@amaitland
Copy link
Member

Thinking about this a little more, are you sure this is the best solution? My original idea was that once the render process had been initialized the root objects could be reused. Are you using standard popups and having problems?

@cefsharp-ms
Copy link
Contributor Author

I fixed the naming and leftover method, I'm sorry, I missed those.

@cefsharp-ms Are you able to add a test case to one of the examples?

Yep, I'll put together something.

Thinking about this a little more, are you sure this is the best solution? My original idea was that once the render process had been initialized the root objects could be reused. Are you using standard popups and having problems?

I wasn't clear about the exact use case here. I'm using custom popups and I wanted to have separate objects bound to the popups. And this caused a few problems, hence my change. However it just hit me that for standard popups the original PR would have changed the previous behavior, so I modified it a bit to have the bound objects from the 'main' browser as default values for all popups.

@amaitland
Copy link
Member

I fixed the naming and leftover method, I'm sorry, I missed those.

Thanks 👍

Yep, I'll put together something.

Much appreciated.

I wasn't clear about the exact use case here. I'm using custom popups and I wanted to have separate objects bound to the popups. And this caused a few problems, hence my change.

That makes more sense. Thanks for clarifying.

Will take it for a spin when I get a few minutes (hopefully next week sometime).

_javascriptRootObjects->default[browser->GetIdentifier()] = syncRoot;

//let's store the non-popup browser's root objects to have default values for the popups
if (!browser->IsPopup())
Copy link
Member

Choose a reason for hiding this comment

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

Would it be cleaner to move the assignment for the popup objects into the branch of the if statement then do a simple HasKey check above? Remove the need for https://github.com/cefsharp/CefSharp/pull/1562/files#diff-a27ca20dcc4f76e2dde0c785dd2abb9cR50

Overall I think we can make the intent a little cleaner to follow. Open to other suggestions

Copy link
Member

Choose a reason for hiding this comment

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

Ideally I'd still like to simplify this.

@cefsharp-ms cefsharp-ms force-pushed the multitenantsubprocess branch 2 times, most recently from 411149d to e46fd4d Compare May 11, 2016 11:24
@cefsharp-ms
Copy link
Contributor Author

Hi,
sorry for the delay on this. I've added an example demonstrating the problem.

Also it seems like something has changed the timing for some events since the upgrade to 49 so I needed to apply another approach to the binding, now it basically pauses the first resource load until the bindings are ready. Otherwise in case of the popups the context creation was too early, and the bound objects for the popups were not sent over before that.

I know it's a pretty big change, but please review it and let's talk about it.

@amaitland
Copy link
Member

I know it's a pretty big change, but please review it and let's talk about it.

I've had a quick look (might be quite some time before I can go over this properly). In my opinion the only way to justify making such drastic changes would be to continue the refactor and remove process-per-tab.

https://github.com/cefsharp/CefSharp/blob/cefsharp/49/CefSharp.Core/CefSettings.h#L38

@cefsharp-ms cefsharp-ms force-pushed the multitenantsubprocess branch 2 times, most recently from b0d9cde to 843f762 Compare August 30, 2016 11:48
@cefsharp-ms
Copy link
Contributor Author

So I have long overdue update on this one. Sorry about that.
Basically I made the bound object handling behavior switchable, so by default people can stick to the old one, and they can switch on the new one on demand, hence there is no need for cryptic code paths in the subprocess.
Also I removed the process-par-tab switch, because the OnBeforeResourceLoad solution for sending over the binding data proved to be working properly.

@cefsharp-ms cefsharp-ms force-pushed the multitenantsubprocess branch from 843f762 to ae18a9f Compare September 1, 2016 10:58
@amaitland
Copy link
Member

You can now bind objects by name in different web pages, should also apply for frames and popups though I haven't tested yet. See #2246 for details.

@amaitland amaitland closed this Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants