Seems SendProcessMessage doesnt send to the correct process

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.

Seems SendProcessMessage doesnt send to the correct process

Postby zj0363637 » Sun Oct 15, 2017 10:53 pm

HI,

I'm trying to prevent page navigation based on policies according the the suggestion in below link:

viewtopic.php?f=6&t=10394

Which suggests:
1. Cancel all requests on OnBeforeNavigation.
2. Send a message to the browser process with the relevant request information (URL, headers, etc).
3. Evaluate the information in the browser process and either:
A. Open the link in an external browser, or
B. Ignore the request, or
C. Call CefBrowser::LoadRequest to re-start the request.

The default address is "about:blank", and if navigating to "https://www.google.com", it actually creates two renderer process, and sending BeforeNavigationMessage back to browser process (from log below its in the google renderer process), however it seems when the browser process trying to send a confirmation message back to renderer process, it always goes to the "about:blank" renderer process:

[1016/143235.495:INFO:client_app_renderer.cc(104)] OnBrowserCreated id: 2 ProcessId:18272
[1016/143235.495:INFO:client_app_renderer.cc(104)] OnBrowserCreated id: 2 ProcessId:10900
[1016/143235.499:INFO:client_app_renderer.cc(120)] OnBeforeNavigation process id: 10900 URL:about:blank
[1016/143235.500:INFO:client_app_renderer.cc(120)] OnBeforeNavigation process id: 18272 URL:https://www.google.com
[1016/143235.500:INFO:client_app_renderer.cc(137)] Sending Before Navigation Message: Current Process Id: 18272 BrowserId: 2
[1016/143235.502:INFO:client_app_renderer.cc(587)] Receiving message in: 10900 for:18272

I'm using CEF Version: 3.3163.1671.g700dc25

Thanks
Jim
zj0363637
Newbie
 
Posts: 4
Joined: Sun Oct 15, 2017 10:37 pm

Re: Seems SendProcessMessage doesnt send to the correct proc

Postby magreenblatt » Mon Oct 16, 2017 3:48 am

Where/how are you loading google.com? Where/when are you sending the message that arrives in the about:blank renderer after the google.com load??
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Seems SendProcessMessage doesnt send to the correct proc

Postby zj0363637 » Mon Oct 16, 2017 4:29 pm

Where/how are you loading google.com?
I'm creating the browser using CreateBrowserSync with "about:blank" as start url, then call LoadURL to navigate to google.com.

Where/when are you sending the message that arrives in the about:blank renderer after the google.com load??
I intercept OnBeforeNavigation in the renderer process, and return false if its "about:blank" otherwise send a message to browser process (browser->SendProcessMessage(PID_BROWSER, message);) and return true, the browser process will validate the url and if allowed then send a message back (browser->SendProcessMessage(PID_RENDERER, message);)

For more information, I've turned on --process-per-site flag, and seems another renderer process is created and will never be destroyed, which causes message always being sent to wrong process, something to do with OnBeforeNavigation cancelling.

I found another post which seems very similar to the issue I'm facing. however the ticket was marked as wont fix, not sure why.
viewtopic.php?f=6&t=10573

Thanks for looking into this.
zj0363637
Newbie
 
Posts: 4
Joined: Sun Oct 15, 2017 10:37 pm

Re: Seems SendProcessMessage doesnt send to the correct proc

Postby magreenblatt » Mon Oct 16, 2017 10:11 pm

The new process will not be created until after the navigation commits. So, OnBeforeNavigation will be called in the current renderer, then you navigate, then the new renderer is created (OnLoadStart called). At that point your process messages should go to the new renderer.

The process-per-site flag is not supported so behaviors using that flag are undefined/untested.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 94 guests