From ecc00f149f24d92b889aff067db29ea9a254954a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 11:55:54 -0500 Subject: [PATCH] fix: prevent gc monitor 2nd pass crash (#47165) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: reito --- shell/common/gin_converters/osr_converter.cc | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/shell/common/gin_converters/osr_converter.cc b/shell/common/gin_converters/osr_converter.cc index afa868ae8a52..2cdb2bb0633f 100644 --- a/shell/common/gin_converters/osr_converter.cc +++ b/shell/common/gin_converters/osr_converter.cc @@ -143,19 +143,21 @@ v8::Local Converter::ToV8( // texture, output it in second pass callback. data.SetSecondPassCallback([](const v8::WeakCallbackInfo< OffscreenReleaseHolderMonitor>& data) { - auto* iso = data.GetIsolate(); // Emit warning only once static std::once_flag flag; std::call_once(flag, [=] { - electron::util::EmitWarning( - iso, - "[OSR TEXTURE LEAKED] When using OSR with " - "`useSharedTexture`, `texture.release()` " - "must be called explicitly as soon as the texture is " - "copied to your rendering system. " - "Otherwise, it will soon drain the underlying " - "framebuffer and prevent future frames from being generated.", - "SharedTextureOSRNotReleased"); + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( + FROM_HERE, base::BindOnce([] { + electron::util::EmitWarning( + "Offscreen rendering shared texture was garbage " + "collected before calling `release()`. When using OSR " + "with `useSharedTexture: true`, `texture.release()` " + "must be called explicitly as soon as the texture is " + "copied to your rendering system. Otherwise, it will " + "soon drain the underlying frame pool and prevent " + "future frames from being sent.", + "OSRSharedTextureNotReleased"); + })); }); }); }