Skip to content

Commit

Permalink
Fix ARC objects leak in MetalShaderCompiler thread
Browse files Browse the repository at this point in the history
When using async shader compilation, the compiler thread pool is a 
standard pthread and not an NSThread. Therefore, it needs a manual
@autorelease pool, otherwise ARC objects never get truly released. 

BUGS=[383167935]
  • Loading branch information
pixelflinger committed Dec 10, 2024
1 parent 6b7080e commit 03fdadf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions filament/backend/src/metal/MetalShaderCompiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ bool isReady() const noexcept {
CompilerPriorityQueue const priorityQueue = program.getPriorityQueue();
mCompilerThreadPool.queue(priorityQueue, token,
[this, name, device = mDevice, program = std::move(program), token]() {
MetalFunctionBundle compiledProgram = compileProgram(program, device);
token->set(compiledProgram);
mCallbackManager.put(token->handle);
@autoreleasepool {
MetalFunctionBundle compiledProgram = compileProgram(program, device);
token->set(compiledProgram);
mCallbackManager.put(token->handle);
}
});

break;
Expand Down

0 comments on commit 03fdadf

Please sign in to comment.