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

AccessViolationException while taking a screenshot #2308

Closed
marci4 opened this issue Mar 8, 2018 · 4 comments
Closed

AccessViolationException while taking a screenshot #2308

marci4 opened this issue Mar 8, 2018 · 4 comments
Milestone

Comments

@marci4
Copy link

marci4 commented Mar 8, 2018

  • What version of the product are you using?
    Nuget: 63.0.2
<packages>
  <package id="cef.redist.x64" version="3.3239.1723" targetFramework="net452" />
  <package id="cef.redist.x86" version="3.3239.1723" targetFramework="net452" />
  <package id="CefSharp.Common" version="63.0.2" targetFramework="net452" />
  <package id="CefSharp.OffScreen" version="63.0.2" targetFramework="net452" />
</packages>
  • What architecture x86 or x64?
    Both x64 and x86

  • On what operating system?
    Win10

  • Are you using WinForms, WPF or OffScreen?
    OffScreen

  • What steps will reproduce the problem?
    In general:
    Changing the size of a browser and taking then a screenshot from this after the website was loaded again
    Example:
    Check out this fork

  • What is the expected output? What do you see instead?
    Expected:
    The size of the bitmap gets updated when I set the size of the browser.
    Current:
    The size of the bitmap differs from the size of the browser and therefore causes an AccessViolationException

  • Please provide any additional information below.

Exception thrown: 'System.AccessViolationException' in System.Drawing.dll
CefSharp.OffScreen.dll!CefSharp.OffScreen.ChromiumWebBrowser.ScreenshotOrNull(CefSharp.OffScreen.PopupBlending blend) Line 510	
CefSharp.OffScreen.dll!CefSharp.OffScreen.ChromiumWebBrowser.ScreenshotAsync.AnonymousMethod__1(object sender, CefSharp.OnPaintEventArgs e) Line 544
CefSharp.OffScreen.dll!CefSharp.OffScreen.ChromiumWebBrowser.CefSharp.Internals.IRenderWebBrowser.OnPaint(CefSharp.Internals.BitmapInfo bitmapInfo) Line 775 	CefSharp.Core.dll!CefSharp::Internals::RenderClientAdapter::OnPaint(scoped_refptr<CefBrowser>* browser, cef_paint_element_type_t type, std::vector<CefRect,std::allocator<CefRect> >& dirtyRects, void* buffer, int width, int height) Line 18
@marci4 marci4 changed the title AccessViolationException while taking a screenshot and AccessViolationException while taking a screenshot Mar 8, 2018
@amaitland amaitland added this to the 65.0.0 milestone Mar 21, 2018
@amaitland
Copy link
Member

amaitland commented Mar 21, 2018

As part of #2237 the way rendering for the OffScreen and WPF projects is done has been rewritten, I've run a slightly modified version of your code (OnPaint event is now Paint, there is now a virtual OnPaint method which is more consistent with the other projects). I changed the counter to 100 and it ran through without exception.

The main difference is that the buffer is stored as a byte[] now, rather than a Bitmap, and a Bitmap is only created upon request, this should improve performance and actually greatly simplifies the code.

@amaitland
Copy link
Member

Closing this as I'm not unable to reproduce with master, you can try one of the CI builds listed at https://github.com/cefsharp/CefSharp#releases-1 to try it out ASAP.

Will likely be some more changes as part of #2237 so subscribe to that issue to be notified of updates.

@gfox1984
Copy link

Sorry to ask, but I'm having the same problem (see closed duplicate above). I'm not sure what you did to fix the problem? Do we have to wait for version 65?

@gfox1984
Copy link

gfox1984 commented Jun 12, 2018

OK I tested with "65.0.0-pre01" and I confirm the exception is gone, without requiring any change to my code.

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

No branches or pull requests

3 participants