Skip to content

Commit

Permalink
fix buffer lock
Browse files Browse the repository at this point in the history
  • Loading branch information
hlwhl authored May 6, 2023
1 parent b9fd9d4 commit 53c7da7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions windows/webview_cef_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ namespace webview_cef {
std::unique_ptr<uint8_t> backing_pixel_buffer;
std::mutex buffer_mutex_;
std::unique_ptr<flutter::TextureVariant> m_texture = std::make_unique<flutter::TextureVariant>(flutter::PixelBufferTexture([](size_t width, size_t height) -> const FlutterDesktopPixelBuffer* {
buffer_mutex_.lock();
auto buffer = pixel_buffer.get();
// Only lock the mutex if the buffer is not null
// (to ensure the release callback gets called)
if (buffer) {
// Gets unlocked in the FlutterDesktopPixelBuffer's release callback.
buffer_mutex_.lock();
if (!buffer) {
buffer_mutex_.unlock();
}
return buffer;
}));
Expand Down

0 comments on commit 53c7da7

Please sign in to comment.