Page 1 of 1

CEF 3.33239 - renderer no longer gets OnLoadingStateChange ?

PostPosted: Tue Jan 30, 2018 7:21 pm
by HarmlessDave
Up through at least 3.2924 both the browser and renderer processes received OnLoadingStateChange events, but now I only see the browser event.

Am I missing something, or do I need to send messages to the renderer process myself if I want it to do something like inject JavaScript once a document has (more or less) loaded?

Re: CEF 3.33239 - renderer no longer gets OnLoadingStateChan

PostPosted: Tue Jan 30, 2018 10:53 pm
by amaitland
Could be related to https://bitbucket.org/chromiumembedded/ ... navigation

There is a command line arg to use the old behavior, might be worth a try.

Re: CEF 3.33239 - renderer no longer gets OnLoadingStateChan

PostPosted: Wed Jan 31, 2018 3:32 am
by ndesktop
Looking in source of 3239 branch:
Code: Select all
void CefBrowserImpl::OnLoadingStateChange(bool isLoading) {
  CefRefPtr<CefApp> app = CefContentClient::Get()->application();
  if (app.get()) {
    CefRefPtr<CefRenderProcessHandler> handler = app->GetRenderProcessHandler();
    if (handler.get()) {
      CefRefPtr<CefLoadHandler> load_handler = handler->GetLoadHandler();
      if (load_handler.get()) {
        WebView* web_view = render_view()->GetWebView();
        const bool canGoBack = webkit_glue::CanGoBack(web_view);
        const bool canGoForward = webkit_glue::CanGoForward(web_view);

        load_handler->OnLoadingStateChange(this, isLoading, canGoBack,
                                           canGoForward);
      }
    }
  }
}


Looking from source it should be invoked in renderer. (Browser is invoked from libcef/browser/browser_host_impl.cc in CefBrowserHostImpl::LoadingStateChanged).
CefRenderProcessHandler implements GetLoadHandler and returns a CefLoadHandler (either the this or a delegate) which in turn implements OnLoadingStateChange.

CefBrowserImpl::OnLoadingStateChange (from libcef/renderer/browser_impl.cpp) is invoked from CefBrowserImpl::DidStartLoading/DidStopLoading.
The only way to not be invoked would be that CefBrowserImpl::DidStartLoading is not invoked, which I found hard to believe.

Re: CEF 3.33239 - renderer no longer gets OnLoadingStateChan

PostPosted: Wed Jan 31, 2018 6:17 am
by amaitland
Chromium is actively removing navigation code from the render process, CefCefRenderProcessHandler::OnBeforeNavigation will be removed for example.

Re: CEF 3.33239 - renderer no longer gets OnLoadingStateChan

PostPosted: Wed Jan 31, 2018 8:25 am
by ndesktop
Then for the time being I don't see other solution other than messaging between renderer and browser, as you pointed out.

Re: CEF 3.33239 - renderer no longer gets OnLoadingStateChan

PostPosted: Wed Jan 31, 2018 11:59 am
by HarmlessDave
Thanks all. It was on our to-do list to shift navigation event code from the render process to the browser process eventually, it sounds like we should do it now and get it over with.