roadlabs / chromiumembedded

Automatically exported from code.google.com/p/chromiumembedded
0 stars 1 forks source link

CEF3: NotificationRegistrar CalledOnValidThread() assertion during shutdown with multi-threaded message loop #755

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Launch CefClient in debug mode
2. Load any page with Flash (such as http://www.youtube.com/watch?v=06_uCl_Bovs)
3. Quit CefClient

What is the expected output? What do you see instead?
CefClient should quit without hitting any break point nor issuing any error.
CefClient hits two break points in CefShutdown() and the corresponding two 
error reports are logged.

What version of the product are you using? On what operating system?
CEF 8.1180.823 on Windows 7 32bits with VS2008

Please provide any additional information below.
Beside hitting the break points when in debug mode, I did not see any unwanted 
behavior.
However, I think it can't be good that the non-thread-safe 
NotificationRegistrar is called on a non-valid thread.

The two errors cited above:
    [1010/172338:FATAL:notification_registrar.cc(79)] Check failed: CalledOnValidThread().
    Backtrace:
       cef_browser_host_create_browser [0x0F525B21+788825]
       cef_browser_host_create_browser [0x0F51213F+708471]
       cef_time_from_doublet [0x105FFAF9+16486105]
       cef_time_from_doublet [0x105FF4A6+16484486]
       cef_time_from_doublet [0x1083E646+18840102]
       cef_time_from_doublet [0x1083E536+18839830]
       cef_time_from_doublet [0x10844F1F+18866943]
       cef_time_from_doublet [0x10843816+18861046]
       cef_browser_host_create_browser [0x0F544137+913263]
       cef_browser_host_create_browser [0x0F5440F8+913200]
       cef_browser_host_create_browser [0x0F5440B5+913133]
       cef_browser_host_create_browser [0x0F5427CF+906759]
       cef_browser_host_create_browser [0x0F542465+905885]
       cef_browser_host_create_browser [0x0F5420FA+905010]
       cef_time_from_doublet [0x10582DE6+15974854]
       cef_time_from_doublet [0x10582DA2+15974786]
       cef_time_from_doublet [0x10582141+15971617]
       cef_browser_host_create_browser [0x0F5BA7BD+1398261]
       cef_browser_host_create_browser [0x0F5B9820+1394264]
       cef_browser_host_create_browser [0x0F5B8979+1390513]
       cef_browser_host_create_browser [0x0F4699B5+18413]
       CefShutdown [0x013C09FC+12] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\libcef_dll\wrapper\libcef_dll_wrapper.cc:151)
       wWinMain [0x0137661E+638] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\cefclient\cefclient_win.cpp:119)
       __tmainCRTStartup [0x0140AD05+357] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:263)
       wWinMainCRTStartup [0x0140AB8F+15] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:182)
       BaseThreadInitThunk [0x76461114+18]
       RtlInitializeExceptionChain [0x77B7B299+99]
       RtlInitializeExceptionChain [0x77B7B26C+54]

    [1010/172344:FATAL:non_thread_safe_impl.cc(12)] Check failed: CalledOnValidThread().
    Backtrace:
       cef_browser_host_create_browser [0x0F525B21+788825]
       cef_browser_host_create_browser [0x0F51213F+708471]
       DelayedLowerToken [0x10DB8D10+2050112]
       cef_string_multimap_free [0x0F5F7F46+78390]
       cef_time_from_doublet [0x105FF4B9+16484505]
       cef_time_from_doublet [0x1083E646+18840102]
       cef_time_from_doublet [0x1083E536+18839830]
       cef_time_from_doublet [0x10844F1F+18866943]
       cef_time_from_doublet [0x10843816+18861046]
       cef_browser_host_create_browser [0x0F544137+913263]
       cef_browser_host_create_browser [0x0F5440F8+913200]
       cef_browser_host_create_browser [0x0F5440B5+913133]
       cef_browser_host_create_browser [0x0F5427CF+906759]
       cef_browser_host_create_browser [0x0F542465+905885]
       cef_browser_host_create_browser [0x0F5420FA+905010]
       cef_time_from_doublet [0x10582DE6+15974854]
       cef_time_from_doublet [0x10582DA2+15974786]
       cef_time_from_doublet [0x10582141+15971617]
       cef_browser_host_create_browser [0x0F5BA7BD+1398261]
       cef_browser_host_create_browser [0x0F5B9820+1394264]
       cef_browser_host_create_browser [0x0F5B8979+1390513]
       cef_browser_host_create_browser [0x0F4699B5+18413]
       CefShutdown [0x013C09FC+12] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\libcef_dll\wrapper\libcef_dll_wrapper.cc:151)
       wWinMain [0x0137661E+638] (c:\users\jr250175\documents\projets\2012-03-28 - tcs connection client\etudes\chromium emdedded\cef_binary_3.1180.823_windows\cefclient\cefclient_win.cpp:119)
       __tmainCRTStartup [0x0140AD05+357] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:263)
       wWinMainCRTStartup [0x0140AB8F+15] (f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c:182)
       BaseThreadInitThunk [0x76461114+18]
       RtlInitializeExceptionChain [0x77B7B299+99]
       RtlInitializeExceptionChain [0x77B7B26C+54]

Original issue reported on code.google.com by jeremie....@gmail.com on 11 Oct 2012 at 3:35

GoogleCodeExporter commented 9 years ago
Original forum post: http://magpcss.org/ceforum/viewtopic.php?f=6&t=4859

You mention in the forum post that you're using --multi-threaded-message-loop. 
Is this setting required to get the above error?

Original comment by magreenb...@gmail.com on 11 Oct 2012 at 3:38

GoogleCodeExporter commented 9 years ago
Yes sorry, the error happens when the application is launched with 
--multi-threaded-message-loop flag (i.e. CEF is configured with 
multi-threaded-message-loop = true)

Original comment by jeremie....@gmail.com on 11 Oct 2012 at 3:41

GoogleCodeExporter commented 9 years ago
I am now seeing this as well. This happens on Win with 
multi-threaded-message-loop set to true.
It happens for me if I load a page via http (i.e. http://mydomain/mytest.htm) 
that contains an image with a src attribute that specifies the https protocol 
(i.e. <img src="https://www.google.com/images/srpr/logo3w.png">). When I load 
that page then quit CEF, I get an assert in the same spot. An excerpt of the 
stack trace is below.

[0221/153120:FATAL:notification_registrar.cc(79)] Check failed: 
CalledOnValidThread(). 
Backtrace:
    base::debug::StackTrace::StackTrace [0x0F8B1B61+33] (c:\src\chromium\src\base\debug\stack_trace_win.cc:171)
    logging::LogMessage::~LogMessage [0x0F89DF9F+63] (c:\src\chromium\src\base\logging.cc:565)
    content::NotificationRegistrar::RemoveAll [0x10B7B939+153] (c:\src\chromium\src\content\public\browser\notification_registrar.cc:86)
    content::NotificationRegistrar::~NotificationRegistrar [0x10B7B2E6+22] (c:\src\chromium\src\content\public\browser\notification_registrar.cc:42)
    content::CertStoreImpl::~CertStoreImpl [0x10DD6ED6+102] (c:\src\chromium\src\content\browser\cert_store_impl.cc:53)
    content::CertStoreImpl::`scalar deleting destructor' [0x10DD6DC6+22]
    DefaultSingletonTraits<content::CertStoreImpl>::Delete [0x10DDD7AF+63] (c:\src\chromium\src\base\memory\singleton.h:59)
    Singleton<content::CertStoreImpl,DefaultSingletonTraits<content::CertStoreImpl>,content::CertStoreImpl>::OnExit [0x10DDC0A6+22] (c:\src\chromium\src\base\memory\singleton.h:275)

Original comment by jmay...@google.com on 21 Feb 2013 at 11:35

GoogleCodeExporter commented 9 years ago
@#3: Can you post the complete stack trace as an attachment? Thanks.

Original comment by magreenb...@gmail.com on 21 Feb 2013 at 11:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
here is a copy of the stack trace

Original comment by jmay...@google.com on 22 Feb 2013 at 12:54

Attachments:

GoogleCodeExporter commented 9 years ago
This assertion occurs consistently when using "multi-threaded-message-loop" if 
you exit the application during active network traffic. For example, run 
cefclient with the following flags and then exit the application:

--multi-threaded-message-loop --enable-media-stream 
--url=http://apprtc.appspot.com/

Original comment by magreenb...@gmail.com on 8 Mar 2013 at 9:56

GoogleCodeExporter commented 9 years ago
The problem is that CertStoreImpl is a singleton and it owns a 
NotificationRegistrar instance. Singletons are destroyed by AtExitManager on 
the main application thread. NotificationRegistrar, on the other hand, needs to 
be destroyed on the UI thread. With multi-threaded message loop mode these are 
not the same thread and this leads to the assertion when the 
NotificationRegistrar is destroyed.

Original comment by magreenb...@gmail.com on 5 Apr 2013 at 6:25

GoogleCodeExporter commented 9 years ago
Filed with Chromium as 
https://code.google.com/p/chromium/issues/detail?id=227100. We'll see what 
solution they recommend.

Original comment by magreenb...@gmail.com on 5 Apr 2013 at 6:44

GoogleCodeExporter commented 9 years ago
Hi
any news on this? We have an app built arround latest cef3 id we ran into this 
issue. I am even ready to look into this, but need some clues on where and how 
to start.
Thanks

Original comment by sor...@gmail.com on 26 Aug 2013 at 1:53

GoogleCodeExporter commented 9 years ago
Issue 1158 has been merged into this issue.

Original comment by magreenb...@gmail.com on 19 Dec 2013 at 6:04

GoogleCodeExporter commented 9 years ago
Same issue when calling multi-threaded-message-loop=true;

Here is the code change to the client sample and part of the debug.log contents.
  AppGetSettings(settings);
  settings.multi_threaded_message_loop = true;
  settings.log_severity = LOGSEVERITY_ERROR;
This happends exit causing the application to crash/hang. Process never exists.

[0120/184635:FATAL:context.cc(178)] Check failed: false. called on invalid 
thread
Backtrace:
    cef_time_delta [0x015C16F1+1906865]
    cef_time_delta [0x0151957F+1218367]
    cef_browser_host_create_browser [0x0132EF17+693221]
    cef_browser_host_create_browser [0x0128D058+29990]
    CefQuitMessageLoop [0x010DB08C+12] (d:\src\cef\libcef_dll\wrapper\libcef_dll_wrapper.cc:259)
    AppQuitMessageLoop [0x0107FB26+182] (d:\src\cef\cefclient\cefclient_win.cpp:671)
    ClientHandler::OnBeforeClose [0x010C5D3E+734] (d:\src\cef\cefclient\client_handler.cpp:384)
    life_span_handler_on_before_close [0x01105B9C+156] (d:\src\cef\libcef_dll\cpptoc\life_span_handler_cpptoc.cc:191)
    cef_browser_host_create_browser [0x012EDBF5+426179]
    cef_string_multimap_free [0x0137E2E7+69751]
    cef_string_multimap_free [0x01380BCF+80223]
    cef_string_multimap_free [0x0137A24E+53214]
    cef_string_multimap_free [0x0137E16B+69371]
    cef_time_delta [0x014231BC+209788]
    gapfnScSendMessage [0x765A62FA+818]
    GetThreadDesktop [0x765A6D3A+215]
    GetThreadDesktop [0x765A6DE8+389]
    GetThreadDesktop [0x765A6E44+481]
    KiUserCallbackDispatcher [0x7748010A+46]
    PeekMessageW [0x765B0751+407]
    cef_time_delta [0x015C405B+1917467]
    cef_time_delta [0x015C4EA4+1921124]
    cef_time_delta [0x015C47F1+1919409]
    cef_time_delta [0x015C3CC2+1916546]
    cef_time_delta [0x015C3F7C+1917244]
    cef_time_delta [0x01522367+1254695]
    cef_time_delta [0x0152213E+1254142]
    cef_time_delta [0x01592C59+1715737]
    cef_time_delta [0x0152198B+1252171]
    cef_time_delta [0x01591E66+1712166]
    cef_time_delta [0x015920AB+1712747]
    cef_time_delta [0x01538291+1344593]
    BaseThreadInitThunk [0x76AF336A+18]
    RtlInitializeExceptionChain [0x774A9F72+99]
    RtlInitializeExceptionChain [0x774A9F45+54]

Original comment by justin.r...@gmail.com on 20 Jan 2014 at 5:51

GoogleCodeExporter commented 9 years ago
Another related debug assertion from trunk revision 1610:

[0210/134206:FATAL:notification_registrar.cc(76)] Check failed: 
CalledOnValidThread(). 
Backtrace:
    base::debug::StackTrace::StackTrace [0x1045DBF1+33] (c:\code\chromium_writable\src\base\debug\stack_trace_win.cc:207)
    logging::LogMessage::~LogMessage [0x103AD7EF+63] (c:\code\chromium_writable\src\base\logging.cc:574)
    content::NotificationRegistrar::RemoveAll [0x1050C4D9+153] (c:\code\chromium_writable\src\content\public\browser\notification_registrar.cc:83)
    content::NotificationRegistrar::~NotificationRegistrar [0x1050BB06+22] (c:\code\chromium_writable\src\content\public\browser\notification_registrar.cc:42)
    content::WebRTCInternals::~WebRTCInternals [0x1080663E+94] (c:\code\chromium_writable\src\content\browser\media\webrtc_internals.cc:66)
    content::WebRTCInternals::`scalar deleting destructor' [0x10806DA6+22]
    DefaultSingletonTraits<content::WebRTCInternals>::Delete [0x1080735F+63] (c:\code\chromium_writable\src\base\memory\singleton.h:59)
    Singleton<content::WebRTCInternals,DefaultSingletonTraits<content::WebRTCInternals>,content::WebRTCInternals>::OnExit [0x10807ED6+22] (c:\code\chromium_writable\src\base\memory\singleton.h:275)
    base::internal::RunnableAdapter<void (__cdecl*)(void *)>::Run [0x1044D157+39] (c:\code\chromium_writable\src\base\bind_internal.h:171)
    base::internal::InvokeHelper<0,void,base::internal::RunnableAdapter<void (__cdecl*)(void *)>,void __cdecl(void * const &)>::MakeItSo [0x1044CD58+24] (c:\code\chromium_writable\src\base\bind_internal.h:872)
    base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void (__cdecl*)(void *)>,void __cdecl(void *),void __cdecl(void *)>,void __cdecl(void *)>::Run [0x1044D115+69] (c:\code\chromium_writable\src\base\bind_internal.h:1169)
    base::Callback<void __cdecl(void)>::Run [0x103150BF+47] (c:\code\chromium_writable\src\base\callback.h:401)
    base::AtExitManager::ProcessCallbacksNow [0x1044CE55+229] (c:\code\chromium_writable\src\base\at_exit.cc:73)
    base::AtExitManager::~AtExitManager [0x1044CA9A+266] (c:\code\chromium_writable\src\base\at_exit.cc:41)
    base::AtExitManager::`scalar deleting destructor' [0x142ED246+22]
    base::DefaultDeleter<base::AtExitManager>::operator() [0x142ED186+54] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:137)
    base::internal::scoped_ptr_impl<base::AtExitManager,base::DefaultDeleter<base::AtExitManager> >::reset [0x142EFB5F+79] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:247)
    scoped_ptr<base::AtExitManager,base::DefaultDeleter<base::AtExitManager> >::reset [0x142EFAFA+26] (c:\code\chromium_writable\src\base\memory\scoped_ptr.h:367)
    content::ContentMainRunnerImpl::Shutdown [0x142EF6B1+417] (c:\code\chromium_writable\src\content\app\content_main_runner.cc:824)
    CefContext::FinalizeShutdown [0x101E2165+101] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:404)
    CefContext::Shutdown [0x101E31D2+322] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:326)
    CefShutdown [0x101E2055+357] (c:\code\chromium_writable\src\cef\libcef\browser\context.cc:147)
    cef_shutdown [0x1013F575+37] (c:\code\chromium_writable\src\cef\libcef_dll\libcef_dll.cc:179)
    CefShutdown [0x00461FBC+12] (c:\code\chromium_writable\src\cef\libcef_dll\wrapper\libcef_dll_wrapper.cc:167)
    wWinMain [0x00459E37+887] (c:\code\chromium_writable\src\cef\tests\cefclient\cefclient_win.cpp:171)
    __tmainCRTStartup [0x0068A8B8+296] (f:\dd\vctools\crt\crtw32\startup\crt0.c:251)
    wWinMainCRTStartup [0x0068A9FD+13] (f:\dd\vctools\crt\crtw32\startup\crt0.c:165)
    BaseThreadInitThunk [0x75C3850D+14]
    RtlInitializeExceptionChain [0x778DBF39+133]
    RtlInitializeExceptionChain [0x778DBF0C+88]

Original comment by magreenb...@gmail.com on 10 Feb 2014 at 6:59

GoogleCodeExporter commented 9 years ago
Fixed in trunk revision 1837, 2062 branch revision 1838 and 1916 branch 
revision 1839.

Original comment by magreenb...@gmail.com on 18 Sep 2014 at 7:12

GoogleCodeExporter commented 9 years ago
@#14: Filed with Chromium as https://codereview.chromium.org/575283004/

Original comment by magreenb...@gmail.com on 18 Sep 2014 at 7:40