Skip to content

Commit

Permalink
WPF - Exception on wakeup from sleep
Browse files Browse the repository at this point in the history
Issue #4426
  • Loading branch information
amaitland committed Sep 2, 2023
1 parent 2e2b53f commit becbb9e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CefSharp.Wpf/Rendering/WritableBitmapRenderHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
return;
}
var sourceBufferPtr = sourceBuffer.DangerousGetHandle();
// Issue https://github.com/cefsharp/CefSharp/issues/4426
if (sourceBufferPtr == IntPtr.Zero)
{
return;
}
//By default we'll only update the dirty rect, for those that run into a MILERR_WIN32ERROR Exception (#2035)
//it's desirably to either upgrade to a newer .Net version (only client runtime needs to be installed, not compiled
//against a newer version. Or invalidate the whole bitmap
Expand All @@ -169,7 +177,7 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
var sourceRect = new Int32Rect(dirtyRect.X, dirtyRect.Y, dirtyRect.Width, dirtyRect.Height);
bitmap.Lock();
bitmap.WritePixels(sourceRect, sourceBuffer.DangerousGetHandle(), noOfBytes, stride, dirtyRect.X, dirtyRect.Y);
bitmap.WritePixels(sourceRect, sourceBufferPtr, noOfBytes, stride, dirtyRect.X, dirtyRect.Y);
bitmap.Unlock();
}
else
Expand All @@ -178,7 +186,7 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
var sourceRect = new Int32Rect(0, 0, width, height);
bitmap.Lock();
bitmap.WritePixels(sourceRect, sourceBuffer.DangerousGetHandle(), noOfBytes, stride);
bitmap.WritePixels(sourceRect, sourceBufferPtr, noOfBytes, stride);
bitmap.Unlock();
}
}
Expand Down

0 comments on commit becbb9e

Please sign in to comment.