mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix macOS builds.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Channels;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using OpenToolkit.GraphicsLibraryFramework;
|
||||
using Robust.Shared;
|
||||
@@ -12,6 +13,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
{
|
||||
private sealed partial class GlfwWindowingImpl
|
||||
{
|
||||
// glfwPostEmptyEvent is broken on macOS and crashes when not called from the main thread
|
||||
// (despite what the docs claim, and yes this makes it useless).
|
||||
// Because of this, we just forego it and use glfwWaitEventsTimeout on macOS instead.
|
||||
private static readonly bool IsMacOS = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
private bool _windowingRunning;
|
||||
private ChannelWriter<CmdBase> _cmdWriter = default!;
|
||||
private ChannelReader<CmdBase> _cmdReader = default!;
|
||||
@@ -47,7 +53,10 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
while (_windowingRunning)
|
||||
{
|
||||
GLFW.WaitEvents();
|
||||
if (IsMacOS)
|
||||
GLFW.WaitEventsTimeout(0.008);
|
||||
else
|
||||
GLFW.WaitEvents();
|
||||
|
||||
while (_cmdReader.TryRead(out var cmd))
|
||||
{
|
||||
@@ -148,7 +157,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
_cmdWriter.TryWrite(cmd);
|
||||
|
||||
// Post empty event to unstuck WaitEvents if necessary.
|
||||
GLFW.PostEmptyEvent();
|
||||
if (!IsMacOS)
|
||||
GLFW.PostEmptyEvent();
|
||||
}
|
||||
|
||||
private void SendEvent(EventBase ev)
|
||||
|
||||
Reference in New Issue
Block a user