From 0f4304edd1a3bcf3631219c1d01ce0a2bd08fa89 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sun, 15 Jan 2023 12:36:15 -0400 Subject: [PATCH 1/3] Pump events a couple times during bootup. Fixes unexpectedly slow first frames on macOS. Fixes #1859 --- src/modules/love/boot.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/love/boot.lua b/src/modules/love/boot.lua index bec1f66ba..038cab634 100644 --- a/src/modules/love/boot.lua +++ b/src/modules/love/boot.lua @@ -304,6 +304,13 @@ function love.init() end end + -- The first couple event pumps on some systems (e.g. macOS) can take a + -- while. We'd rather hit that slowdown here than in event processing + -- within the first frames. + if love.event then + for i = 1, 2 do love.event.pump() end + end + -- Our first timestep, because window creation can take some time if love.timer then love.timer.step() From 02d2dc94274302e80a0f727620e72bc96c8267b9 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Wed, 18 Jan 2023 17:27:06 -0400 Subject: [PATCH 2/3] Fix race condition when a thread is destroyed right after thread:start --- src/modules/thread/sdl/Thread.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/modules/thread/sdl/Thread.cpp b/src/modules/thread/sdl/Thread.cpp index 02be5e433..aa69b9276 100644 --- a/src/modules/thread/sdl/Thread.cpp +++ b/src/modules/thread/sdl/Thread.cpp @@ -48,13 +48,24 @@ bool Thread::start() #endif Lock l(mutex); + if (running) return false; + if (thread) // Clean old handle up SDL_WaitThread(thread, nullptr); + + // Keep the threadable around until the thread is done with it. + // This is done before thread_runner executes because there can be a delay + // between CreateThread and the start of the thread code's execution. + t->retain(); + thread = SDL_CreateThread(thread_runner, t->getThreadName(), this); running = (thread != nullptr); + if (!running) + t->release(); // thread_runner is never called in this situation. + return running; } @@ -80,7 +91,6 @@ bool Thread::isRunning() int Thread::thread_runner(void *data) { Thread *self = (Thread *) data; // some compilers don't like 'this' - self->t->retain(); self->t->threadFunction(); @@ -89,6 +99,7 @@ int Thread::thread_runner(void *data) self->running = false; } + // This was retained in start(). self->t->release(); return 0; } From 9963d1247c05b303caf7c61e8016315a1cd33465 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Mon, 30 Jan 2023 09:41:02 -0400 Subject: [PATCH 3/3] update windows build status URL --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 148d09023..11f9f2d6f 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, macOS, Linux, Android, and iOS. -[![Build Status: Windows](https://ci.appveyor.com/api/projects/status/chc0hdr08wv1d5c7?svg=true)](https://ci.appveyor.com/project/AlexSzpakowski/love) +[![Build Status: Windows](https://ci.appveyor.com/api/projects/status/chc0hdr08wv1d5c7?svg=true)](https://ci.appveyor.com/project/slime73/love) [![Build Status: Github CI](https://github.com/love2d/love/workflows/continuous-integration/badge.svg)](https://github.com/love2d/love/actions?query=workflow%3Acontinuous-integration) Documentation