From 58275329cc2e0158d994fe3950ce6498c4bc0388 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Wed, 24 May 2023 12:37:17 -0700 Subject: [PATCH] Minor WebAssembly adjustments --- project/include/system/System.h | 2 ++ project/src/backend/sdl/SDLApplication.cpp | 8 ++++++++ project/src/backend/sdl/SDLWindow.cpp | 4 +++- project/src/system/System.cpp | 22 ++++++++++++++++++++++ tools/platforms/WebAssemblyPlatform.hx | 4 ++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/project/include/system/System.h b/project/include/system/System.h index 23cfb7bb9..ec67cdd16 100644 --- a/project/include/system/System.h +++ b/project/include/system/System.h @@ -28,6 +28,8 @@ namespace lime { static void GCEnterBlocking (); static void GCExitBlocking (); + static void GCTryEnterBlocking (); + static void GCTryExitBlocking (); static bool GetAllowScreenTimeout (); static std::wstring* GetDeviceModel (); static std::wstring* GetDeviceVendor (); diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp index 190b7e52b..85e64fa1b 100644 --- a/project/src/backend/sdl/SDLApplication.cpp +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -928,8 +928,16 @@ namespace lime { void SDLApplication::UpdateFrame () { + #ifdef EMSCRIPTEN + System::GCTryExitBlocking (); + #endif + currentApplication->Update (); + #ifdef EMSCRIPTEN + System::GCTryEnterBlocking (); + #endif + } diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 59ff7435f..e58103f3e 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -201,7 +201,9 @@ namespace lime { // if (window->flags & WINDOW_FLAG_VSYNC) { - // sdlRendererFlags |= SDL_RENDERER_PRESENTVSYNC; + #ifdef EMSCRIPTEN + sdlRendererFlags |= SDL_RENDERER_PRESENTVSYNC; + #endif // } diff --git a/project/src/system/System.cpp b/project/src/system/System.cpp index 820a3d4a6..4385ae268 100644 --- a/project/src/system/System.cpp +++ b/project/src/system/System.cpp @@ -42,6 +42,28 @@ namespace lime { } + void System::GCTryEnterBlocking () { + + if (!_isHL) { + + gc_try_blocking (); + + } + + } + + + void System::GCTryExitBlocking () { + + if (!_isHL) { + + gc_try_unblocking (); + + } + + } + + #if defined (HX_WINDOWS) && !defined (HX_WINRT) std::wstring* GetWMIValue (BSTR query, BSTR field) { diff --git a/tools/platforms/WebAssemblyPlatform.hx b/tools/platforms/WebAssemblyPlatform.hx index d79827769..b7e48b255 100644 --- a/tools/platforms/WebAssemblyPlatform.hx +++ b/tools/platforms/WebAssemblyPlatform.hx @@ -206,6 +206,10 @@ class WebAssemblyPlatform extends PlatformTarget args.push("ASSERTIONS=1"); } + // set initial size + args.push("-s"); + args.push("TOTAL_MEMORY=32MB"); + if (project.targetFlags.exists("final")) { args.push("-O3");