CEF 2785+ shutdown hangs in single process mode

Issue #1993 wontfix
Lead Assimilator
created an issue

CEF in single process mode with a multi-threaded message loop hangs during shutdown due to Chromium changes made by https://codereview.chromium.org/2029623002. Other scenarios may hang as well, but have not been tested.

Attached is a patch tested on 2785 to libcef/renderer/content_renderer_client.cc that fixes the hang by moving the existing call to content::RenderProcessHost::SetRunRendererInProcess(false) prior to the host cleanup loop. When set to false prior to cleanup instead of after, the quick return check during host cleanup is bypassed and the cleanup proceeds as it did prior to the aforementioned Chromium changes.

Also the changes in https://codereview.chromium.org/1942273002 need reverted because they force a crash during the cef shutdown procedure.

Comments (7)

  1. David Desmaisons

    I am experimenting similar problem: CEF in single process mode with a multi-threaded message loop hangs during shutdown with version 3.2883.1539. Is this issue still relevant?

  2. danakj

    This is caused by the if condition in CefContentRendererClient here:

    https://github.com/bkeiren/cef/blob/aefb5ccce879f308f0bcc3ac719c86defe2f9715/libcef/renderer/content_renderer_client.cc#L686

    It says:

      // Deletion of the RenderProcessHost object will stop the render thread and
      // result in a call to WillDestroyCurrentMessageLoop.
      // Cleanup() will cause deletion to be posted as a task on the UI thread but
      // this task will only execute when running in multi-threaded message loop
      // mode (because otherwise the UI message loop has already stopped).
    

    However Cleanup does not delete the RenderProcessHost in single-process mode anymore.

    // Therefore we need to explicitly delete the object when not running in this mode.
    

    This now applies to multi-thread mode as well. Before it said that Cleanup() would fail to cause the delete to happen in non-multi-thread-mode since the MessageLoop is gone. But it just doesn't delete it at all now in single-process.

    So instead of

    if (!multi_threaded_message_loop)
      delete host;
    

    It should do

    if (single_process_mode || !multi_threaded_message_loop)
      delete host;
    

    As CleanUp()'s "delete this" does not run in either scenario.

    Alternatively, RunSingleProcessCleanupOnUIThread() could post a task to the UI thread to unblock the main thread instead of waiting for WillDestroyCurrentMessageLoop, which is not reliable.

  3. Log in to comment