Truly independent web browser
LibWeb: Keep the image codec plugin per agent
Andreas Kling11935e1719d8
diff --git a/Libraries/LibWeb/Platform/ImageCodecPlugin.cpp b/Libraries/LibWeb/Platform/ImageCodecPlugin.cppindex 61136d424ae..542c6f4a2ac 100644--- a/Libraries/LibWeb/Platform/ImageCodecPlugin.cpp+++ b/Libraries/LibWeb/Platform/ImageCodecPlugin.cpp@@ -9,7 +9,8 @@namespace Web::Platform {-static ImageCodecPlugin* s_the;+// An agent talks to the decoder over a connection of its own, which only its thread can use.+static thread_local ImageCodecPlugin* s_the;ImageCodecPlugin::~ImageCodecPlugin() = default;@@ -25,4 +26,10 @@ void ImageCodecPlugin::install(ImageCodecPlugin& plugin)s_the = &plugin;}+void ImageCodecPlugin::shut_down()+{+ delete s_the;+ s_the = nullptr;+}+}diff --git a/Libraries/LibWeb/Platform/ImageCodecPlugin.h b/Libraries/LibWeb/Platform/ImageCodecPlugin.hindex 5ca20c7d439..94a638e6436 100644--- a/Libraries/LibWeb/Platform/ImageCodecPlugin.h+++ b/Libraries/LibWeb/Platform/ImageCodecPlugin.h@@ -42,6 +42,9 @@ public:static ImageCodecPlugin& the();static void install(ImageCodecPlugin&);+ // For an agent that goes away, whose pending decodes hold on to its heap. Takes the plugin that was installed with new.+ static void shut_down();+virtual ~ImageCodecPlugin();virtual NonnullRefPtr<Core::Promise<DecodedImage>> decode_image(ReadonlyBytes, ESCAPING Function<ErrorOr<void>(DecodedImage&)> on_resolved, ESCAPING Function<void(Error&)> on_rejected) = 0;