From c6d6b041193e5981f995d0fa419d8d5a5ba99fe4 Mon Sep 17 00:00:00 2001 From: Yurii Nakonechnyi Date: Fri, 25 Sep 2020 00:39:20 +0300 Subject: [PATCH] Added GLFW error-callback into FlutterEmbedderGLFW (#19998) GLFW Error callback useful to clarify reasons of 'glfwInit()' failure. On some platforms/desktop environments may be really strange failure reasons, like (in my case): "Linux: Failed to initialize inotify: Too many open files", so descriptive error messages helps to solve problem. --- examples/glfw/FlutterEmbedderGLFW.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/glfw/FlutterEmbedderGLFW.cc b/examples/glfw/FlutterEmbedderGLFW.cc index 4dfffad4e600b..419630a733cd0 100644 --- a/examples/glfw/FlutterEmbedderGLFW.cc +++ b/examples/glfw/FlutterEmbedderGLFW.cc @@ -129,6 +129,10 @@ void printUsage() { << std::endl; } +void GLFW_ErrorCallback(int error, const char* description) { + std::cout << "GLFW Error: (" << error << ") " << description << std::endl; +} + int main(int argc, const char* argv[]) { if (argc != 3) { printUsage(); @@ -138,6 +142,8 @@ int main(int argc, const char* argv[]) { std::string project_path = argv[1]; std::string icudtl_path = argv[2]; + glfwSetErrorCallback(GLFW_ErrorCallback); + int result = glfwInit(); assert(result == GLFW_TRUE);