Skip to content

Commit

Permalink
Fix deadlock on startup in a saner way
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jun 17, 2023
1 parent abf1256 commit 7beb127
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Veldrid/MTL/MTLGraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static readonly Dictionary<IntPtr, MTLGraphicsDevice> s_aotRegisteredBlo

private readonly IMTLDisplayLink _displayLink;
private readonly AutoResetEvent _nextFrameReadyEvent;
private readonly AutoResetEvent _frameEndedEvent = new AutoResetEvent(true);
private readonly EventWaitHandle _frameEndedEvent = new EventWaitHandle(true, EventResetMode.ManualReset);

public MTLDevice Device => _device;
public MTLCommandQueue CommandQueue => _commandQueue;
Expand All @@ -62,7 +62,6 @@ public override void UpdateActiveDisplay(int x, int y, int w, int h)
{
if (_displayLink != null)
{
_frameEndedEvent.Set();
_displayLink.UpdateActiveDisplay(x, y, w, h);
}
}
Expand Down Expand Up @@ -248,6 +247,7 @@ private protected override void SubmitCommandsCore(CommandList commandList, Fenc

private protected override void WaitForNextFrameReadyCore()
{
_frameEndedEvent.Reset();
_nextFrameReadyEvent?.WaitOne(TimeSpan.FromSeconds(1)); // Should never time out.
}

Expand Down

0 comments on commit 7beb127

Please sign in to comment.