Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ internal class MetalRedrawer(
caDisplayLink?.invalidate()
caDisplayLink = null

// Wait until all scheduled rendering tasks are completed to eliminate race conditions
// when clearing the resources
if (useSeparateRenderThreadWhenPossible) {
trace("MetalRedrawer:dispose:waitForAsyncRenderingTasks") {
dispatch_sync(renderingDispatchQueue) {}
}
}

pictureRecorder.close()
context.close()
}
Expand Down Expand Up @@ -431,6 +439,9 @@ internal class MetalRedrawer(
picture.close()
surface.flushAndSubmit()

surface.close()
renderTarget.close()

if (useSeparateRenderThreadWhenPossible) {
dispatch_semaphore_signal(drawCanvasSemaphore)
}
Expand Down Expand Up @@ -470,9 +481,6 @@ internal class MetalRedrawer(
}
}

surface.close()
renderTarget.close()

// Track current inflight command buffers to synchronously wait for their schedule in case app goes background
inflightCommandBuffers.add(commandBuffer)

Expand Down