diff --git a/impeller/playground/playground.cc b/impeller/playground/playground.cc index 1f1c5930ff864..3df9001bc753d 100644 --- a/impeller/playground/playground.cc +++ b/impeller/playground/playground.cc @@ -30,6 +30,11 @@ #include "third_party/imgui/backends/imgui_impl_glfw.h" #include "third_party/imgui/imgui.h" +#if FML_OS_MACOSX +#include +#include +#endif + namespace impeller { std::string PlaygroundBackendToString(PlaygroundBackend backend) { @@ -178,6 +183,23 @@ void Playground::SetCursorPosition(Point pos) { cursor_position_ = pos; } +#if FML_OS_MACOSX +class AutoReleasePool { + public: + AutoReleasePool() { + pool_ = reinterpret_cast(objc_msgSend)( + objc_getClass("NSAutoreleasePool"), sel_getUid("new")); + } + ~AutoReleasePool() { + reinterpret_cast(objc_msgSend)(pool_, sel_getUid("drain")); + } + + private: + typedef id (*msg_send)(void*, SEL); + id pool_; +}; +#endif + bool Playground::OpenPlaygroundHere( const Renderer::RenderCallback& render_callback) { if (!is_enabled()) { @@ -239,6 +261,9 @@ bool Playground::OpenPlaygroundHere( ::glfwShowWindow(window); while (true) { +#if FML_OS_MACOSX + AutoReleasePool pool; +#endif ::glfwPollEvents(); if (::glfwWindowShouldClose(window)) {