Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OffScreen multithreading result gives fault in libcef.dll #2965

Closed
kevingoos opened this issue Nov 7, 2019 · 11 comments
Closed

OffScreen multithreading result gives fault in libcef.dll #2965

kevingoos opened this issue Nov 7, 2019 · 11 comments
Labels

Comments

@kevingoos
Copy link

Bug Report

  • What version of the product are you using?

    • Nuget version: v75.1.143
  • What architecture x86 or x64?

    • x64
  • On what operating system?

    • Win10 or Windows server 2016 (tested both)
  • Are you using WinForms, WPF or OffScreen?

    • OffScreen
  • What steps will reproduce the problem?

    • I run multiple browsers in an async task. And then it starts crashing.
  • What is the expected output? What do you see instead?

    • Expected output is just screenshot.
    • In the event viewer I see the following error:

Faulting application name: CefSharpTest.exe, version: 1.0.0.0, time stamp: 0xe55eb49f
Faulting module name: libcef.dll, version: 75.1.14.0, time stamp: 0x5d071e50
Exception code: 0xc0000005
Fault offset: 0x02ef19f1
Faulting process id: 0x27b8
Faulting application start time: 0x01d595782d5b9745
Faulting application path: C:\Users\EXJ508\source\repos\CefSharpTest\CefSharpTest\bin\Debug\CefSharpTest.exe
Faulting module path: C:\Users\EXJ508\source\repos\CefSharpTest\CefSharpTest\bin\Debug\x86\libcef.dll
Report Id: e5198fa2-f4d0-4e44-9422-01dfe067fc98
Faulting package full name:
Faulting package-relative application ID:

@kevingoos kevingoos changed the title OffScreen multithreading result in fault in libcef.dll OffScreen multithreading result gives fault in libcef.dll Nov 7, 2019
@amaitland
Copy link
Member

  • In the event viewer I see the following error:

There's nothing usable here, you need to get a proper stacktrace. Download http://opensource.spotify.com/cefbuilds/cef_binary_75.1.14%2Bgc81164e%2Bchromium-75.0.3770.100_windows64_release_symbols.tar.bz2 and extract the libcef.dll.pdb next to libcef.dll.

Link is broken, please fix.

This will likely be closed as upstream as a crash in libcef would need to be fixed in CEF in most cases.

@kevingoos
Copy link
Author

kevingoos commented Nov 8, 2019

A sorry the link is fixed: https://github.com/kevingoos/CefSharpTest

I am trying to get more info out of it, but I cannot find any way... I added the pdb files but no extra info
It keeps crashing:
afbeelding

This is what I get in the debug.log file:


[1107/150432.334:ERROR:shader_disk_cache.cc(258)] Failed to create shader cache entry: -2
[1107/152451.307:WARNING:backend_impl.cc(1638)] Messed up entry found.
[1107/152451.308:WARNING:backend_impl.cc(1846)] Destroying invalid entry.
[1107/152603.286:INFO:CONSOLE(56)] "<link rel=preload> must have a valid `as` value", source: https://www.youtube.com/watch?v=KyZArQMFhQ4 (56)
[1107/152603.839:INFO:CONSOLE(0)] "Refused to display 'https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fhl%3Den%26app%3Ddesktop%26next%3D%252Fsignin_passive%26feature%3Dpassive%26action_handle_signin%3Dtrue&uilel=3&service=youtube&passive=true&hl=en' in a frame because it set 'X-Frame-Options' to 'deny'.", source: https://www.youtube.com/watch?v=KyZArQMFhQ4 (0)
[1107/152604.242:INFO:CONSOLE(0)] "HTML Imports is deprecated and will be removed in M73, around March 2019. Please use ES modules instead. See https://www.chromestatus.com/features/5144752345317376 for more details.", source:  (0)
[1107/152609.761:INFO:CONSOLE(0)] "The resource https://r2---sn-cxaoxucx-cg0e.googlevideo.com/generate_204?conn2 was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.", source:  (0)
[1107/152609.761:INFO:CONSOLE(0)] "The resource https://r2---sn-cxaoxucx-cg0e.googlevideo.com/generate_204 was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.", source:  (0)
[1107/152609.763:INFO:CONSOLE(0)] "The resource https://i.ytimg.com/generate_204 was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.", source:  (0)
[1108/162547.451:ERROR:broker_win.cc(55)] Error reading broker pipe: The pipe has been ended. (0x6D)
[1108/162659.586:INFO:child_thread_impl.cc(746)] ChildThreadImpl::EnsureConnected()
[1108/162659.827:INFO:child_thread_impl.cc(746)] ChildThreadImpl::EnsureConnected()

I have no further clue where to look...

@kevingoos
Copy link
Author

I enabled native code debugging...

And I get the following:
afbeelding

With call stack:

	libcef.dll!printing::PrintJobManager::queue() Line 80	C++
 	libcef.dll!printing::CefPrintViewManagerBase::CefPrintViewManagerBase(content::WebContents * web_contents) Line 69	C++
 	libcef.dll!printing::CefPrintViewManager::CefPrintViewManager(content::WebContents * web_contents) Line 161	C++
 	libcef.dll!content::WebContentsUserData<printing::CefPrintViewManager>::CreateForWebContents(content::WebContents * contents) Line 40	C++
 	libcef.dll!CefBrowserHostImpl::CefBrowserHostImpl(const CefStructBase<CefBrowserSettingsTraits> & settings, scoped_refptr<CefClient> client, content::WebContents * web_contents, scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserHostImpl> opener, scoped_refptr<CefRequestContextImpl> request_context, std::__1::unique_ptr<CefBrowserPlatformDelegate,std::__1::default_delete<CefBrowserPlatformDelegate>> platform_delegate, scoped_refptr<CefExtension> extension) Line 2872	C++
 	libcef.dll!CefBrowserHostImpl::CreateInternal(const CefStructBase<CefBrowserSettingsTraits> & settings, scoped_refptr<CefClient> client, content::WebContents * web_contents, bool own_web_contents, scoped_refptr<CefBrowserInfo> browser_info, scoped_refptr<CefBrowserHostImpl> opener, bool is_devtools_popup, scoped_refptr<CefRequestContextImpl> request_context, std::__1::unique_ptr<CefBrowserPlatformDelegate,std::__1::default_delete<CefBrowserPlatformDelegate>> platform_delegate, scoped_refptr<CefExtension> extension) Line 426	C++
 	libcef.dll!CefBrowserHostImpl::Create(CefBrowserHostImpl::CreateParams & create_params) Line 370	C++
 	libcef.dll!CefBrowserHost::CreateBrowserSync(const CefWindowInfo & windowInfo, scoped_refptr<CefClient> client, const CefStringBase<CefStringTraitsUTF16> & url, const CefStructBase<CefBrowserSettingsTraits> & settings, scoped_refptr<CefDictionaryValue> extra_info, scoped_refptr<CefRequestContext> request_context) Line 289	C++
 	libcef.dll!`anonymous namespace'::CreateBrowserWithHelper(`anonymous namespace'::CreateBrowserHelper * helper) Line 142	C++
 	libcef.dll!base::internal::Invoker<base::internal::BindState<void (*)(base::Thread *),base::Thread *>,void ()>::RunOnce(base::internal::BindStateBase * base) Line 641	C++
 	libcef.dll!base::TaskAnnotator::RunTask(const char * trace_event_name, base::PendingTask * pending_task) Line 114	C++
 	libcef.dll!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow * continuation_lazy_now, bool * ran_task) Line 364	C++
 	libcef.dll!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoSomeWork() Line 216	C++
 	libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 219	C++
 	libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate) Line 77	C++
 	libcef.dll!base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool application_tasks_allowed, base::TimeDelta timeout) Line 448	C++
 	libcef.dll!base::RunLoop::RunWithTimeout(base::TimeDelta timeout) Line 161	C++
 	libcef.dll!base::RunLoop::Run() Line 130	C++
 	libcef.dll!CefUIThread::ThreadMain() Line 350	C++
 	libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) Line 100	C++
 	kernel32.dll!74c38674()	Unknown
 	kernel32.dll![Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	Unknown
 	ntdll.dll!76fb5e17()	Unknown
 	ntdll.dll!76fb5de7()	Unknown

@amaitland amaitland added upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium. invalid and removed upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium. labels Nov 8, 2019
@amaitland
Copy link
Member

Making as invalid for now, it's mostly likely a bug in your code.

Cef.IsInitialized is not thread safe as Cef.Initialize and Cef.Shutdown should be called on your main application thread (and they need to both be called on the same thread). See https://github.com/cefsharp/CefSharp/wiki/General-Usage#initialize-and-shutdown for some background. Restructure your program so Cef.Initialize is called in Program.cs, follow the example in #1714 for how to hook AppDomain.CurrentDomain.AssemblyResolve before any assemblies are loaded. You'll also need to add say a CancellationToken to handle closing of your Task, stop your timer, dispose of the browser etc.

@kevingoos
Copy link
Author

Thx moving the intialize is the sollution...

@UweKeim
Copy link

UweKeim commented Nov 14, 2019

I'm getting the same error in my WinForms application recently on several customer PCs, too. Worked very well since month/years.

The issue occurs when exiting the application. It works correctly from start to finish, the error only occurs after the application is closed.

The issue also occurs only randomly. I.e. not on every exit, but only sometimes. Other times, no error occurs.

Name der fehlerhaften Anwendung: producer-core.exe, Version: 15.2.0.0, Zeitstempel: 0x5dc588e7
Name des fehlerhaften Moduls: libcef.dll, Version: 75.1.14.0, Zeitstempel: 0x5d071e50
Ausnahmecode: 0xc0000005
Fehleroffset: 0x00000000020a190c
ID des fehlerhaften Prozesses: 0x11cc
Startzeit der fehlerhaften Anwendung: 0x01d59a06b123d5c1
Pfad der fehlerhaften Anwendung: C:\Users\sseiz_admin\AppData\Local\Zeta Producer 15\Applications\producer-core.exe
Pfad des fehlerhaften Moduls: C:\Users\sseiz_admin\AppData\Local\Zeta Producer 15\Applications\x64\libcef.dll
Berichtskennung: 8bb83e25-f1f0-4b9c-8449-afd3472282ce
Vollständiger Name des fehlerhaften Pakets:
Anwendungs-ID, die relativ zum fehlerhaften Paket ist:

Happens on Windows 7 primarily. I'm wild-guessing that a more recent NuGet update of CefSharp introduced this.


Currently I'm not calling Cef.Shutdown. I'm adding a call now.

@LFDCC
Copy link

LFDCC commented Nov 19, 2019

Have you solved your problem? I have the same problem

@kevingoos
Copy link
Author

So in my case, I moved the Cef.Initialize and the Cef.Shutdown outside the thread in the main program. And this solves the problem for me...

@UweKeim
Copy link

UweKeim commented Nov 19, 2019

If @LFDCC is refering to my posting, I do not have yet enough user feedback, whether the addition of Cef.Shutdown helped.

@amaitland
Copy link
Member

The issue outlined here is very specified to calling Cef.Intiailize in a non thread safe fashion (as I've detailed above Cef.IsInitialized is not thread safe). The 0xc0000005 exception code is very generic, it's not specific to either issue. https://stackoverflow.com/a/5303952/4583726 provides a nice and succinct summary.

Intermittent crash on shutdown is caused by the new Network Service, see https://bitbucket.org/chromiumembedded/cef/issues/2703/crash-when-closing-if to workaround you can disable the Network Service example at #2743 (comment)

As per the Known Issues section of the 75.1.141 Release Notes. What you are seeing is most likely a bug in CEF.

@gfox1984
Copy link

I am using CefSharp Offscreen and started encountering this issue in production after upgrading to version 75.

My code was already calling Initialize and Shutdown on the main thread, so I had a look at the example given by @amaitland:

example at #2743 (comment)

and I can confirm that adding this line of code solved the problem for me:

settings.CefCommandLineArgs.Add("disable-features", "NetworkService,VizDisplayCompositor");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants