You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Javascript Bound objects no longer registered after cross-site navigationΒ #1203
I did a few experiments, but it seems like the new render process won't receive the messages sent to PID_RENDERER until the old one closes + some time (I actually found a thread describing something like this: http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10573&p=16293&hilit=domain+new+render+process#p16293). This usually means that the context is already created when messages are starting to get through to the new render process π ...it still seems like the only stable point in time to transmit things is the callback where extensions are getting forwarded.
I'm testing --process-per-tab for a while now and it seems to solve this for regular browser instances. However the new context for the popups are created before the OnRenderViewReady is called, so the bound objects are unavailable in the custom popups.
I've removed quite a few of the old comments. If your comment has been deleted it's nothing personal, just keeping the size of the overall issue down.
Now to clarify a few points, the problem still exists any the latest 63.0.0-pre01 release (3239 branch)
will --renderer-process-limit=1 not help?
@jogibear9988 With code changes it could be made to work, the current implementation does not support that scenario, see #2142
In CEF Python I do javascript bindings:
After browser is created sending IPC message
In renderer process every time OnContextCreated is being called
Seems to be working fine.
@cztomczak This solution would appear to be workable in version 62 and below, unfortunately I'm seeing problems with IPC messaging being sent from OnContextCreated after a render process switch, see http://magpcss.org/ceforum/viewtopic.php?f=6&t=15677 for details. I'd be curious to hear feedback from your testing with the 3239 branch.
The cefclient sample also has a binding test that seems to work ok if I understand correctly.
After browser is created I am sending IPC message from browser process to renderer process. That IPC message contains js bindings and a copy of them is saved for later re-binding in step 2. I create browser synchronously and send js bindings after browser is created, so there may be some delay before js bindings are available, however haven't noticed any issue, in practice browser is still loading after being created.
In renderer process every time OnContextCreated is being called I re-bind js bindings using a copy of data sent in step 1. The data is already available for me to expose it in javascript (or will be available in a moment as it is already being sent in step 1), I don't have to send IPC message from renderer to browser process at this point to get them - as what you described is an issue in v63.
If user modifies js bindings in browser process I send another IPC message as in step 1.
After browser is created I am sending IPC message from browser process to renderer process. That IPC message contains js bindings and a copy of them is saved for later re-binding in step 2. I create browser synchronously and send js bindings after browser is created, so there may be some delay before js bindings are available, however haven't noticed any issue, in practice browser is still loading after being created.
@cztomczak Have you tested with the 3239 branch? When the cross-origin switch occurs I'm seeing messages go missing or sent to the incorrect (old) render process. I've looked at your code and I'd be surprised if you didn't have exactly the same problem, at least with the 3239 branch. Soon as the cross-origin switch occurs the IPC messages aren't delivered reliably.
In renderer process every time OnContextCreated is being called I re-bind js bindings using a copy of data sent in step 1. The data is already available for me to expose it in javascript (or will be available in a moment as it is already being sent in step 1), I don't have to send IPC message from renderer to browser process at this point to get them - as what you described is an issue in v63.
That's what CefSharp did previously, data was sent in OnRenderViewReady, as there was only one render process per browser instance, this was reliable for almost all cases (there is a problem with popups reported above)
No, I haven't yet tested 3239 branch and neither "cross-origin" switch. I haven't had previously the need to expose js bindings to different addresses loaded in browser, so yeah looks like it would be an issue in cefpython, as this would create new renderer processes. However user can always manually rebind js bindings by calling Rebind() func if he knows an address changed (he can using OnBeforeBrowse or similar).
Looks like I've discovered an issue in cefpython, reported (cztomczak/cefpython#406) and referenced the three comments above, so please don't delete them :)
However user can always manually rebind js bindings by calling Rebind() func if he knows an address changed (he can using OnBeforeBrowse or similar).
I tried OnBeforeBrowser and OnBeforeResourceLoad, was unable to get either of them reliably working in the cross-origin switch scenario. I'm basically seeing the same problem as outlined in https://bitbucket.org/chromiumembedded/cef/issues/929#comment-16412458 which I know is very old and marked as wontfix, I was able to reliably reproduce the problem last time I tested.
changed the title [-]The loss of the registered js object[/-][+]Javascript Bound objects no longer registered after cross-site navigation[/+]on Jan 11, 2018
Activity
cefsharp-ms commentedon Aug 25, 2015
I did a few experiments, but it seems like the new render process won't receive the messages sent to PID_RENDERER until the old one closes + some time (I actually found a thread describing something like this: http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10573&p=16293&hilit=domain+new+render+process#p16293). This usually means that the context is already created when messages are starting to get through to the new render process π ...it still seems like the only stable point in time to transmit things is the callback where extensions are getting forwarded.
Implement temp workaround for #1203 - enable process-per-tab by default
amaitland commentedon Sep 8, 2015
Added
--process-per-tabas a temp workaround, will release a new-preshortly and see if there's any feedback.5676672
cefsharp-ms commentedon Sep 8, 2015
I'm testing --process-per-tab for a while now and it seems to solve this for regular browser instances. However the new context for the popups are created before the
OnRenderViewReadyis called, so the bound objects are unavailable in the custom popups.amaitland commentedon Sep 8, 2015
Thanks for the heads up π
amaitland commentedon Sep 15, 2015
Interesting background read can be found at http://magpcss.org/ceforum/viewtopic.php?f=6&t=13386&sid=cf4881bba36a72c96ca7de0e891391de#p27469
May not be practical in a
CefSharpsense, will need to investigate further.Implement temp workaround for cefsharp#1203 - enable process-per-tab β¦
34 remaining items
amaitland commentedon Jan 9, 2018
I've removed quite a few of the old comments. If your comment has been deleted it's nothing personal, just keeping the size of the overall issue down.
Now to clarify a few points, the problem still exists any the latest
63.0.0-pre01release (3239branch)@jogibear9988 With code changes it could be made to work, the current implementation does not support that scenario, see #2142
@cztomczak This solution would appear to be workable in version
62and below, unfortunately I'm seeing problems withIPCmessaging being sent fromOnContextCreatedafter a render process switch, see http://magpcss.org/ceforum/viewtopic.php?f=6&t=15677 for details. I'd be curious to hear feedback from your testing with the3239branch.@japj
cefclientdoes indeed have it's ownbindingfeature, you can see https://bitbucket.org/chromiumembedded/cef/src/master/include/wrapper/cef_message_router.h?at=master&fileviewer=file-view-default#cef_message_router.h-59 for an example of it's usage. In my opinion it's very limited and not worth implementing.amaitland commentedon Jan 9, 2018
I do have an
alphaversion of what I believe to be a workable solution. I will post more information when I've received feedback.cztomczak commentedon Jan 9, 2018
@amaitland
In CEF Python I do javascript bindings:
After browser is created I am sending IPC message from browser process to renderer process. That IPC message contains js bindings and a copy of them is saved for later re-binding in step 2. I create browser synchronously and send js bindings after browser is created, so there may be some delay before js bindings are available, however haven't noticed any issue, in practice browser is still loading after being created.
In renderer process every time OnContextCreated is being called I re-bind js bindings using a copy of data sent in step 1. The data is already available for me to expose it in javascript (or will be available in a moment as it is already being sent in step 1), I don't have to send IPC message from renderer to browser process at this point to get them - as what you described is an issue in v63.
If user modifies js bindings in browser process I send another IPC message as in step 1.
amaitland commentedon Jan 9, 2018
@cztomczak Have you tested with the
3239branch? When thecross-originswitch occurs I'm seeing messages go missing or sent to the incorrect (old) render process. I've looked at your code and I'd be surprised if you didn't have exactly the same problem, at least with the3239branch. Soon as thecross-originswitch occurs theIPCmessages aren't delivered reliably.That's what
CefSharpdid previously, data was sent inOnRenderViewReady, as there was only onerender processper browser instance, this was reliable for almost all cases (there is a problem with popups reported above)Thanks for taking the time to respond π
cztomczak commentedon Jan 9, 2018
No, I haven't yet tested 3239 branch and neither "cross-origin" switch. I haven't had previously the need to expose js bindings to different addresses loaded in browser, so yeah looks like it would be an issue in cefpython, as this would create new renderer processes. However user can always manually rebind js bindings by calling Rebind() func if he knows an address changed (he can using OnBeforeBrowse or similar).
cztomczak commentedon Jan 9, 2018
Looks like I've discovered an issue in cefpython, reported (cztomczak/cefpython#406) and referenced the three comments above, so please don't delete them :)
amaitland commentedon Jan 9, 2018
I tried
OnBeforeBrowserandOnBeforeResourceLoad, was unable to get either of them reliably working in thecross-originswitch scenario. I'm basically seeing the same problem as outlined in https://bitbucket.org/chromiumembedded/cef/issues/929#comment-16412458 which I know is very old and marked aswontfix, I was able to reliably reproduce the problem last time I tested.Understood π
[-]The loss of the registered js object[/-][+]Javascript Bound objects no longer registered after cross-site navigation[/+]amaitland commentedon Jan 22, 2018
See #2246 for details on the new option for binding objects.
amaitland commentedon Jan 25, 2018
The changes in #2246 have been published as part of the
63.0.0-pre02packages which are now onNuget.org.cefsharp-ms commentedon Jan 30, 2018
Just as an addition to this, I submitted a PR towards CEF: https://bitbucket.org/chromiumembedded/cef/pull-requests/147/allow-synchronously-sending-extra_info-to/diff
If/when this is merged, it could be used to transmit bound objects in a sync way.
amaitland commentedon Feb 8, 2018
63.0.0has now been released, see #2246 for details on the newJavascript Bindingimplementation.