| Flutter Impeller |

Public Member Functions | List of all members
impeller::Playground::GLFWInitializer Struct Reference

## Public Member Functions
| GLFWInitializer ()

## Detailed Description

Definition at line 51 of file playground.cc.

## Constructor & Destructor Documentation

## ◆ GLFWInitializer()

impeller::Playground::GLFWInitializer::GLFWInitializer | ( |  | ) |
| inline

Definition at line 52 of file playground.cc.

52 {
53 // This guard is a hack to work around a problem where glfwCreateWindow
54 // hangs when opening a second window after GLFW has been reinitialized (for
55 // example, when flipping through multiple playground tests).
56 //
57 // Explanation:
58 // * glfwCreateWindow calls [NSApp run], which begins running the event
59 // loop on the current thread.
60 // * GLFW then immediately stops the loop when
61 // applicationDidFinishLaunching is fired.
62 // * applicationDidFinishLaunching is only ever fired once during the
63 // application's lifetime, so subsequent calls to [NSApp run] will always
64 // hang with this setup.
65 // * glfwInit resets the flag that guards against [NSApp run] being
66 // called a second time, which causes the subsequent `glfwCreateWindow`
67 // to hang indefinitely in the event loop, because
68 // applicationDidFinishLaunching is never fired.
69 static std::once_flag sOnceInitializer;
70 std::call_once(sOnceInitializer, []() {
71 ::glfwSetErrorCallback([](int code, const char* description) {
72 FML_LOG(ERROR) << "GLFW Error '" << description << "' (" << code
73 << ").";
74 });
75 FML_CHECK(::glfwInit() == GLFW_TRUE);
76 });
77 }

The documentation for this struct was generated from the following file:

- impeller/playground/playground.cc