Linux: multi-threaded-message-loop not working in M88

Issue #3087 resolved
Salvador Diaz Fau created an issue

What steps will reproduce the problem?

  • Download the "Standard Distribution" : https://cef-builds.spotifycdn.com/cef_binary_88.2.4%2Bgf3c4ca9%2Bchromium-88.0.4324.150_linux64.tar.bz2
  • Decompress it and check that the following packages are installed : build-essential, libgtk2.0-dev and libgtkglext1-dev
  • Create the "build" directory with the command : mkdir build && cd build
  • Build the apps using the Unix makefile commands :

    • cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
    • make -j4 cefclient cefsimple
  • Wait until the process reaches 100% and execute the following commands as instructed on the screen (the paths may be different) :

    • EXE="/home/<username>/cef_binary_88.2.4+gf3c4ca9+chromium-88.0.4324.150_linux64/build/tests/cefclient/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
    • EXE="/home/<username>/cef_binary_88.2.4+gf3c4ca9+chromium-88.0.4324.150_linux64/build/tests/cefsimple/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
  • Switch to the directory where cefclient was created and execute "./cefclient --multi-threaded-message-loop" (without quotes).

What is the expected output? What do you see instead?

cefclient should create the window and all the controls the same way it does when you execute “./cefclient” but if you add the --multi-threaded-message-loop switch then the buttons and address bar are missing (see the attached image).

Resizing the window fails the first time. The following resizing attemps change the window size but the browser remains unchanged.

The close button in the window doesn’t work and you need to kill the task.

If you navigate to YouTube using the links from the google.com page it will freeze the application with this message in the debug log :

[0206/110339.358305:ERROR:browser_platform_delegate.cc(229)] Not implemented reached in virtual std::unique_ptr<CefJavaScriptDialogRunner>

What version of the product are you using? On what operating system?

CEF 88.2.4 in Linux Mint 20.1 Cinnamon (64 bits) 

Does the problem reproduce with the cefclient or cefsimple sample application at the same version? How about with a newer or older version? Does the problem reproduce with Google Chrome at the same version? How about with a newer or older version?

The last working cefclient version was in CEF 85.3.13 :
https://cef-builds.spotifycdn.com/cef_binary_85.3.13%2Bgcd6cbe0%2Bchromium-85.0.4183.121_linux64.tar.bz2

CEF 86.0.14 and later versions have this issue.

Related forum thread :
https://magpcss.org/ceforum/viewtopic.php?f=6&t=18146

Comments (16)

  1. Salvador Diaz Fau reporter
    • edited description

    Added the information about the last working cefclient version.

  2. Czarek Tomczak

    I can reproduce the issue with:
    cef_binary_88.2.5+gcab058b+chromium-88.0.4324.150_linux64.tar.bz2
    cef_binary_87.1.14+ga29e9a3+chromium-87.0.4280.141_linux64.tar.bz2
    cef_binary_86.0.24+g85e79d4+chromium-86.0.4240.198_linux64.tar.bz2

    Additionally in off-screen rendering mode you can see a white page.

    The last version that works fine with multi threaded message loop is:
    cef_binary_85.3.13+gcd6cbe0+chromium-85.0.4183.121_linux64.tar.bz2

  3. Marshall Greenblatt

    I suspect this is related to https://crrev.com/b960daf4e6 which landed in the correct time frame (starting with M86). Specifically, It looks like base/message_loop/message_pump_glib.cc RunningOnMainThread() will return false which is not the behavior that we expect with multi-threaded message loop mode. Alternately, perhaps we can start using g_main_context_default() in MainMessageLoopMultithreadedGtk since Chromium is now creating a new context.

  4. Marshall Greenblatt

    Linux: cefclient: Fix GTK behavior with multi-threaded-message-loop (fixes issue #3087)

    Switch to using g_main_context_default() in MainMessageLoopMultithreadedGtk. As of M86 (https://crrev.com/b960daf4e6) Chromium now creates its own context in MessagePumpGlib so we can use the default context in cefclient. This is also more "correct" from a GTK usage perspective. As part of this change all GTK dialogs and callbacks are now executed on the main thread instead of the UI thread (note that these are the same thread when not using multi-threaded-message-loop).

    → <<cset b3ad79e2c5af>>

  5. Marshall Greenblatt

    Linux: cefclient: Fix GTK behavior with multi-threaded-message-loop (fixes issue #3087)

    Switch to using g_main_context_default() in MainMessageLoopMultithreadedGtk. As of M86 (https://crrev.com/b960daf4e6) Chromium now creates its own context in MessagePumpGlib so we can use the default context in cefclient. This is also more "correct" from a GTK usage perspective. As part of this change all GTK dialogs and callbacks are now executed on the main thread instead of the UI thread (note that these are the same thread when not using multi-threaded-message-loop).

    → <<cset 0ee212251274>>

  6. Marshall Greenblatt

    Linux: cefclient: Fix GTK behavior with multi-threaded-message-loop (fixes issue #3087)

    Switch to using g_main_context_default() in MainMessageLoopMultithreadedGtk. As of M86 (https://crrev.com/b960daf4e6) Chromium now creates its own context in MessagePumpGlib so we can use the default context in cefclient. This is also more "correct" from a GTK usage perspective. As part of this change all GTK dialogs and callbacks are now executed on the main thread instead of the UI thread (note that these are the same thread when not using multi-threaded-message-loop).

    → <<cset c18ff5804d7b>>

  7. Czarek Tomczak

    That was fast. Nice work!

    It works, but I get segmentation fault upon exit. My steps reproduce the issue 100% time:

    1. Run ./cefclient --multi-threaded-message-loop
    2. Click Accept Terms on Google → Search for something → Close Window.
    3. Segmentation fault upon exit.

    Reproduces only with multi threaded message loop.

    Thread 8 "Chrome_IOThread" received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7fffd6ffd700 (LWP 56658)]
    Bind () at ../../components/discardable_memory/service/discardable_shared_memory_manager.cc:290
    290 ../../components/discardable_memory/service/discardable_shared_memory_manager.cc: No such file or directory.
    (gdb) bt
    #0  Bind() ()
        at ../../components/discardable_memory/service/discardable_shared_memory_manager.cc:290
    #1  0x00007fffee8fa0db in BindDiscardableMemoryReceiverOnIO() ()
        at ../../content/browser/gpu/gpu_process_host.cc:509
    #2  0x00007fffee8fa11e in Invoke<void (*)(mojo::PendingReceiver<discardable_memory::mojom::DiscardableSharedMemoryManager>,
     discardable_memory::DiscardableSharedMemoryManager*), mojo::PendingReceiver<discardable_memory::mojom::DiscardableSharedMemoryManager>,
     discardable_memory::DiscardableSharedMemoryManager*> () at ../../base/bind_internal.h:393
    #3  MakeItSo<void (*)(mojo::PendingReceiver<discardable_memory::mojom::DiscardableSharedMemoryManager>, 
     discardable_memory::DiscardableSharedMemoryManager*), mojo::PendingReceiver<discardable_memory::mojom::DiscardableSharedMemoryManager>,
     discardable_memory::DiscardableSharedMemoryManager*> ()
        at ../../base/bind_internal.h:637
    #4  RunImpl<void (*)(mojo::PendingReceiver<discardable_memory::mojom::DiscardableSharedMemoryManager>, 
     discardable_memory::DiscardableSharedMemoryManager*), std::tuple<mojo::PendingReceiver<discardable_memory::mojom::
    DiscardableSharedMemoryManager>, discardable_memory::DiscardableSharedMemoryManager*>, 0, 1> () at ../../base/bind_internal.h:710
    #5  RunOnce() () at ../../base/bind_internal.h:679
    #6  0x00007ffff149518b in Run () at ../../base/callback.h:101
    #7  RunTask() () at ../../base/task/common/task_annotator.cc:163
    #8  0x00007ffff14adb4f in DoWorkImpl() ()
        at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:351
    #9  0x00007ffff14ad7d0 in DoWork() ()
        at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:264
    #10 0x00007ffff1539472 in Run() () at ../../base/message_loop/message_pump_libevent.cc:209
    #11 0x00007ffff14ae465 in Run() ()
        at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:460
    #12 0x00007ffff1475b55 in Run() () at ../../base/run_loop.cc:131
    #13 0x00007ffff14d6398 in Run() () at ../../base/threading/thread.cc:311
    #14 0x00007fffee742bb0 in content::BrowserProcessSubThread::IOThreadRun(base::RunLoop*) ()
        at ../../content/browser/browser_process_sub_thread.cc:144
    #15 0x00007fffee742b0c in Run() () at ../../content/browser/browser_process_sub_thread.cc:96
    #16 0x00007ffff14d6831 in ThreadMain() () at ../../base/threading/thread.cc:382
    #17 0x00007ffff15041ee in ThreadFunc() () at ../../base/threading/platform_thread_posix.cc:87
    #18 0x00007fffea12c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
    --Type <RET> for more, q to quit, c to continue without paging--
    #19 0x00007fffea053293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
    

  8. Marshall Greenblatt

    @Czarek Tomczak I’m not seeing that crash with M89 on Ubuntu 18.04. What version and platform are you testing?

  9. Czarek Tomczak

    I am testing on Ubuntu 20.04.2 64-bit. I’ve just re-run and it still always reproduces for me with these two versions I’ve tested:
    cef_binary_89.0.4+g0ee2122+chromium-89.0.4389.40_linux64_beta
    cef_binary_88.2.7+gc18ff58+chromium-88.0.4324.150_linux64

    I am also seeing some GPU errors on exit and then segmentation fault:

    [0215/223823.563337:WARNING:connection.cc(61)] X error received.  Request: DestroyWindowRequest, Error: 
    WindowError{.sequence = 750, .bad_value = 60817413, .minor_opcode = 0, .major_opcode = 4}
    [0215/223823.570531:ERROR:gl_surface_egl.cc(774)] EGL Driver message (Critical) eglMakeCurrent: Failed to make the 
    GLX context current
    [0215/223823.570774:ERROR:gl_surface_egl.cc(774)] EGL Driver message (Critical) eglMakeCurrent: Failed to make the 
    GLX context current
    [0215/223823.571087:ERROR:gl_context_egl.cc(271)] eglDestroyContext failed with error EGL_BAD_CONTEXT
    [0215/223823.655959:WARNING:gpu_process_host.cc(1282)] The GPU process has crashed 1 time(s)
    [0215/223823.656433:WARNING:connection.cc(61)] X error received.  Request: DestroyWindowRequest, Error: 
    WindowError{.sequence = 752, .bad_value = 60817414, .minor_opcode = 0, .major_opcode = 4}
    [Thread 0x7fffba7fc700 (LWP 7953) exited]
    Thread 8 "Chrome_IOThread" received signal SIGSEGV, Segmentation fault.
    

    Without --multi-threaded-message-loop I am also seeing these EGL/GPU errors, but I don’t see the segmentation fault. SIGSEGV only occurs with multi threaded.

  10. Salvador Diaz Fau reporter

    I also get a core dump with cefclient 88.2.8 after I search any term in Google and close cefclient.

    I keep using the same OS and configuration as described before and I execute this command :

    ./cefclient --multi-threaded-message-loop
    

    This is what I see in the console :

    [0216/143718.239176:INFO:content_main_runner_impl.cc(1005)] Chrome is running in full browser mode.
    [0216/143719.679205:WARNING:http_cache_transaction.cc(1184)] Unable to open or create cache entry
    [0216/143719.679298:WARNING:http_cache_transaction.cc(1184)] Unable to open or create cache entry
    [0216/143728.683781:WARNING:http_cache_transaction.cc(1184)] Unable to open or create cache entry
    [0216/143731.812362:WARNING:connection.cc(60)] X error received. Request: x11::DestroyWindowRequest, Error: x11::WindowError{.sequence = 698, .bad_value = 96468997, .minor_opcode = 0, .major_opcode = 4}
    [0216/143731.819946:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Critical) eglMakeCurrent: Failed to make the GLX context current
    [0216/143731.820698:ERROR:gl_surface_egl.cc(773)] EGL Driver message (Critical) eglMakeCurrent: Failed to make the GLX context current
    [0216/143732.165036:WARNING:gpu_process_host.cc(1274)] The GPU process has crashed 1 time(s)
    [0216/143732.165123:WARNING:connection.cc(60)] X error received. Request: x11::DestroyWindowRequest, Error: x11::WindowError{.sequence = 700, .bad_value = 96468998, .minor_opcode = 0, .major_opcode = 4}
    Violación de segmento (`core' generado)
    [0100/000000.254570:INFO:child_thread_impl.cc(838)] ChildThreadImpl::EnsureConnected()

    The last INFO message appears a few seconds after the core dump.

  11. Log in to comment