添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Hello Alex,
How are you? I downloaded CefSharp library from here for understand this and I tried. But I getting some errors. I guess, these are version based errors. Is there any errorless version?

Where the error occurred:
cef_string_wrappers.h: 222

https://drive.google.com/open?id=102Dwsk6q36IH99S5ynnkifiP9rHoFDaj

@amaitland
I am also getting the same exception in WPF version. This is happening after I upgraded from 63.0.3 to 71.0.2 .
Apologies, it is not reproducible consistently, very random & not able to provide much more information at the moment, but trying to figure out.

In the meantime, this is the callstack (if that could give some hint) : Tried to lookup the Error code - says E_FAIL

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at CefBrowserHost.CreateBrowser(CefWindowInfo* , scoped_refptr<CefClient>* , CefStringBase<CefStringTraitsUTF16>* , CefStructBase<CefBrowserSettingsTraits>* , scoped_refptr<CefRequestContext>* )
   at CefSharp.ManagedCefBrowserAdapter.CreateBrowser(IWindowInfo windowInfo, BrowserSettings browserSettings, RequestContext requestContext, String address) in c:\projects\cefsharp\cefsharp.core\managedcefbrowseradapter.cpp:line 33
   at CefSharp.Wpf.ChromiumWebBrowser.CreateOffscreenBrowser(Size size) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 1755
   at CefSharp.Wpf.ChromiumWebBrowser.OnActualSizeChanged(Object sender, SizeChangedEventArgs e) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 1824
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo)
   at System.Windows.ContextLayoutManager.fireSizeChangedEvents()
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Window.SetRootVisual()
   at System.Windows.Window.SetRootVisualAndUpdateSTC()
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

What version of the product are you using?
v71.0.2 via NuGet
https://www.nuget.org/packages/CefSharp.Wpf/71.0.2

What architecture x86 or x64?

On what operating system?
Win7, Version 6.1 Build 7601:Service Pack 1

Are you using WinForms, WPF or OffScreen?

What steps will reproduce the problem?
Unfortunately, it is very random. Not reproducible. Started happening after upgrading from v63.0.3

What is the expected output? What do you see instead?
Web Page should load without exceptions. But, SEHException is thrown randomly when webpage loads. But, even after the exception, web page does loads.

Please provide any additional information below.

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at CefBrowserHost.CreateBrowser(CefWindowInfo* , scoped_refptr<CefClient>* , CefStringBase<CefStringTraitsUTF16>* , CefStructBase<CefBrowserSettingsTraits>* , scoped_refptr<CefRequestContext>* )
   at CefSharp.ManagedCefBrowserAdapter.CreateBrowser(IWindowInfo windowInfo, BrowserSettings browserSettings, RequestContext requestContext, String address) in c:\projects\cefsharp\cefsharp.core\managedcefbrowseradapter.cpp:line 33
   at CefSharp.Wpf.ChromiumWebBrowser.CreateOffscreenBrowser(Size size) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 1755
   at CefSharp.Wpf.ChromiumWebBrowser.OnActualSizeChanged(Object sender, SizeChangedEventArgs e) in C:\projects\cefsharp\CefSharp.Wpf\ChromiumWebBrowser.cs:line 1824
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo)
   at System.Windows.ContextLayoutManager.fireSizeChangedEvents()
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Window.SetRootVisual()
   at System.Windows.Window.SetRootVisualAndUpdateSTC()
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

And, noticed this in Windows Event Viewer Application logs Window:

Faulting application name: CefSharp.BrowserSubprocess.exe, version: 71.0.2.0, time stamp: 0x5c8355fb
Faulting module name: KERNELBASE.dll, version: 6.1.7601.24387, time stamp: 0x5c7f3ad8
Exception code: 0xe0434352
Fault offset: 0x000000000000be0d
Faulting process id: 0x159c
Faulting application start time: 0x01d4eca9ab27b7a7
Faulting application path: C:\source\Source\Bin\Debug\CefSharp.BrowserSubprocess.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: ebdc9d06-589c-11e9-8a7a-64006a7d07f4

Also, could this be related -
https://magpcss.org/ceforum/viewtopic.php?f=6&t=16240

Does the cef log provide any relevant information? (By default there should be a debug.log file in your bin directory)
Noticed this error line in the debug.log (but, not sure it is related or not) - Matched the timestamp roughly.
[0406/195113.071:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.

Any other background information that's relevant? Are you doing something out of the ordinary? 3rd party controls?

Does this problem also occur in the CEF Sample Application from http://opensource.spotify.com/cefbuilds/index.html?

  • Unfortunately, it is very random. Not reproducible. Started happening after upgrading from v63.0.3
  • How many machines are you seeing this on? Are they all running the same hardware?

  • Noticed this error line in the debug.log (but, not sure it is related or not) - Matched the timestamp roughly.
    [0406/195113.071:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.
  • Somewhat indicates that your GPU Process is crashing. Though it's not really definitive.

    Does it crash on Windows 10?

    I am not able to comment on that because my environment is Windows 7

    How many machines are you seeing this on? Are they all running the same hardware?

    Currently, only on my machine as I am developing & testing it out. All machines on which it will eventually get deployed are also Windows 7 and will have pretty much same hardware as mine.

    Somewhat indicates that your GPU Process is crashing. Though it's not really definitive.

    Yes; but, until v63, everything was alright. I just did NuGet update alongwith VC++ 2015 libs. Did not have to change any code drastically.

    I will continue to analyse. Is there a document on how to debug using the CEF Browser sub-process in Visual Studio ? Maybe I can set that up on my machine to debug the native lib (libcef) ?

    Yes; but, until v63, everything was alright. I just did NuGet update alongwith VC++ 2015 libs. Did not have to change any code drastically.

    A LOT has changed in Chromium, you've jumped 8 versions ahead.

    I will continue to analyse. Is there a document on how to debug using the CEF Browser sub-process in Visual Studio ? Maybe I can set that up on my machine to debug the native lib (libcef) ?

    See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#unmanaged-crashes-when-the-process-dies

    I'd probably start with just disabling GPU Acceleration and see if that makes a difference.

    I'd probably start with just disabling GPU Acceleration and see if that makes a difference.

    Thanks. Is this what you are referring -https://cefsharp.github.io/api/63.0.0/html/M_CefSharp_CefSettings_DisableGpuAcceleration.htm

    Is this what you are referring -https://cefsharp.github.io/api/63.0.0/html/M_CefSharp_CefSettings_DisableGpuAcceleration.htm

    Yes, that will work.

    Also I've just released the 73.1.120-pre01 packages. You can try with a newer version.

    @amaitland
    I did disable GPU in v71.0.2 as stated above. But, I am still getting this error in debug.log

    [0415/143619.899:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.

    You can try with a newer version.

    Yet to try this.

    @amaitland

    Additional info on v71 SEHException
    This happens when there is a small 1px Browser inside a Window and moment that window loads, it attempts to create instance of that 1px Browser & it crashes with SEHException.

    XAML:

    <cef:ChromiumWebBrowser x:Name="browser" Width="1" Height="1"/>
    

    NB: I am not trying to load any Address in XAML or in codebehind (until my 1px Browser is fully initialised).

    If I do 25-30 times F5/Restart from VS continuously, this might happen once. At this point, I also noticed, I do not have the CefSharp Browser SubProcess created & I can confirm that by doing CTRL+ALT+P in VS and also via Windows TaskManager. So, I cannot attach and get a detailed native stack trace (although I have the matching libcef.dll.pdb file).

    And, I have also enabled this:
    cefs.CefCommandLineArgs.Add("renderer-startup-dialog", "1");
    But, at this point, since browser creation has failed, even the message box is not rendered.

    I have enabled gitlink, and I see it crashes in:

    CefSharp.Core.dll!<Unknown function> Line 33 C++
    CefSharp.Wpf.dll!CefSharp.Wpf.ChromiumWebBrowser.CreateOffscreenBrowser(System.Windows.Size size) Line 1755	C#
    CefSharp.Wpf.dll!CefSharp.Wpf.ChromiumWebBrowser.OnActualSizeChanged(object sender, System.Windows.SizeChangedEventArgs e) Line 1824	C#
    

    Line 33 in the callstack indicates the method being called by this function inside ManagedCefBrowserAdapter.cpp (which is a native call and since I do not have the Browser sub process, I am unable to provide more detailed callstack)- This is where is stops when it crashes
    while further calling into the C++ layer -

     if (!CefBrowserHost::CreateBrowser(*cefWindowInfoWrapper->GetWindowInfo(), _clientAdapter.get(), addressNative, *browserSettings->_browserSettings, static_cast<CefRefPtr<CefRequestContext>>(requestContext)))
            throw gcnew InvalidOperationException("CefBrowserHost::CreateBrowser call failed, review the CEF log file for more details.");
    

    Latest errors logged inside Debug.log at this point are like this in this sequence -

    [0429/212114.514:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.
    [0429/212211.031:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.
    [0429/212457.057:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.
    

    And, I have this enabled in intialisation code: cefs.SetOffScreenRenderingBestPerformanceArgs();

    @angshuman-agarwal Did you test with v73.1.120-pre01? Many bugs in the CEF OSR implementation have been fixed recently. I would also suggest you create the browser with more realistic dimensions, try like 640x480 or something much larger than 1x1.

    Remove SetOffScreenRenderingBestPerformanceArgs() also and run your tests again. The browser subprocess running won't have any bearing on your ability to capture a call stack for the main process, make sure you have native code debugging enabled in visual studio.

    As it only happens randomly it's unlikely a bug in CefSharp, if it was a bug in CefSharp it should be reliably reproducible.

    For me to look into this any further I will require an example that reproduces the problem and an exact list of steps required. By all means continue debugging on your own.

    Not yet. When will v73 be finally released ?

    I would also suggest you create the browser with more realistic dimensions, try like 640x480 or something much larger than 1x1.

    I cannot, as I am using this browser size for a reason in my App and it has been fine in prior versions including v63

    Remove SetOffScreenRenderingBestPerformanceArgs() also and run your tests again.

    Will do that

    make sure you have native code debugging enabled in visual studio.

    Thanks, will do

    For me to look into this any further I will require an example that reproduces the problem and an exact list of steps required.

    Well, if only I could get that. Hence, I mentioned once in 25-30 times. I will see if in MinimalExample, I can do this scenario.

    For the purpose of debugging you should test with a realistic size, if a larger size works this is likely useful debugging information, doesn't matter if you use this for real in your app.

    What was the last version this worked successfully in? You can quite easily take the branch for that version, upgrade to the same version of CEF then perform your tests. Test with a newer version first.

    Version 69 and 71 both have bugs in the OSR rendering implementation (CEF bugs) that have only been fixed in version 73.

    I suggested disabling the gpu, using SetOffScreenRenderingBestPerformanceArgs() adds two other commands, one of which is no longer relevant and shouldn't be used. The method should be removed as it's implementation is based on outdated advice.

    I suggested disabling the gpu

    Removed SetOffScreenRenderingBestPerformanceArgs and added this instead -cefs.DisableGpuAcceleration();

    I still got this in debug.log
    [0430/102251.586:ERROR:gpu_process_transport_factory.cc(990)] Lost UI shared context.

    But, as you suggested, will keep this change. No idea why the error still shows up.

    leave GPU acceleration enabled is perfectly fine

    I am still on v71, now left GPU acceleration enabled, error is not seen in debug.log. I also compared chrome://gpu. Thank you !!

    I see nothing alarmingly different. Pretty much matches with actual Chrome.
    (my actual Google chrome version is Chrome/72.0.3626.121)

    Graphics Feature Status, Driver Bug Workarounds, Problems Detected all match.

    Now, I will see if I can reproduce the SEHException issue with this setting. If, still yes, then I will upgrade to version pre-73 else leave it.

    @amaitland - Have been incessantly trying to reproduce after the GPU acceleration enabling. Got
    v. tough to reproduce. But, managed to get the same SEHException.

    Now, I see this in debug.log. (with v71) when the SEHException happened.
    Any hints here ? From the sound of it looks like GPU acceleration enabling is now causing WebGL exception ?
    (Am I deadlocked?!)

    [0430/152357.705:ERROR:gl_surface_egl.cc(537)] EGL Driver message (Error) eglCreateWindowSurface: Bad native window.
    [0430/152357.705:ERROR:gl_surface_egl.cc(1068)] eglCreateWindowSurface failed with error EGL_BAD_NATIVE_WINDOW
    [0430/152357.705:ERROR:gles2_command_buffer_stub.cc(223)] ContextResult::kSurfaceFailure: Failed to create surface.
              

    I wanted to add that I get this error:

    An exception of type 'System.Runtime.InteropServices.SEHException' occurred in CefSharp.Core.dll and wasn't handled before a managed/native boundary

    Additional information: External component has thrown an exception.

    at cef_string_utf8_to_utf16(SByte* , UInt32 , _cef_string_utf16_t* )
    at CefStringTraitsUTF16.from_string(basic_string<char,std::char_traits,std::allocator >* str, _cef_string_utf16_t* s) in f:\programming\github\cefsharp\packages\cef.sdk.74.1.13\cef\include\internal\cef_string_wrappers.h:line 223
    at CefStringBase.FromString(CefStringBase* , basic_string<char,std::char_traits,std::allocator >* str) in f:\programming\github\cefsharp\packages\cef.sdk.74.1.13\cef\include\internal\cef_string_wrappers.h:line 579
    at CefStringBase.{ctor}(CefStringBase* , SByte* src) in f:\programming\github\cefsharp\packages\cef.sdk.74.1.13\cef\include\internal\cef_string_wrappers.h:line 316
    at ?A0x247141ed.??__E?A0x247141ed@kEvaluateJavascriptRequest@Messaging@Internals@CefSharp@@YMXXZ() in f:\programming\github\cefsharp\cefsharp.core\internals\messaging\messages.h:line 18
    at _initterm_m((fnptr)* pfbegin, (fnptr)* pfend) in f:\dd\vctools\crt\crtw32\msilcrt\puremsilcode.cpp:line 214
    at .LanguageSupport.InitializePerProcess(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 380
    at .LanguageSupport._Initialize(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 598
    at .LanguageSupport.Initialize(LanguageSupport* ) in f:\dd\vctools\crt\crtw32\msilcrt\mstartup.cpp:line 804

    My implementation is very basic. I created a win32 winform project with the following code:

    Imports CefSharp.Example
    Imports CefSharp.WinForms
    Public Class Form1
        Private Sub Form1_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop
        End Sub
        Private Sub Form1_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim browser As ChromiumWebBrowser = New ChromiumWebBrowser("http://google.com")
        End Sub
    End Class
    

    My implementation was using the latest version: 74.1.3

    @krptodr This is a development version and not production ready, you should be using the latest stable version which is 73.1.130. The next version will be based on 75, there will be no 74 release (as per usual odd versions only)

    I also get the same error on the version that you found, that you did not reveive it: 73.1.130.

    What do you mean? Are you seeing an exception with 73.1.130? Please clarify.

    The SEHException class handles SEH errors that are thrown from unmanaged code, but that have not been mapped to another .NET Framework exception

    As per https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.sehexception?view=netframework-4.8 the SEHException is very much a catch all exception.

    My implementation is very basic. I created a win32 winform project with the following code:

    You stack trace references kEvaluateJavascriptRequest which if you aren't calling explicitly then it's probably a bug in CEF which will be resolved by upgrading to a newer version of Chromium.

    I got error when settings = new CefSettings();
    :cef_string_wrappers.h
    return cef_string_utf8_to_utf16(data, length, s) ? true : false;
    System.Runtime.InteropServices.SEHException: