Skip to content

Commit 03fdadf

Browse files
committed
Fix ARC objects leak in MetalShaderCompiler thread
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]
1 parent 6b7080e commit 03fdadf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

filament/backend/src/metal/MetalShaderCompiler.mm

+5-3
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ bool isReady() const noexcept {
226226
CompilerPriorityQueue const priorityQueue = program.getPriorityQueue();
227227
mCompilerThreadPool.queue(priorityQueue, token,
228228
[this, name, device = mDevice, program = std::move(program), token]() {
229-
MetalFunctionBundle compiledProgram = compileProgram(program, device);
230-
token->set(compiledProgram);
231-
mCallbackManager.put(token->handle);
229+
@autoreleasepool {
230+
MetalFunctionBundle compiledProgram = compileProgram(program, device);
231+
token->set(compiledProgram);
232+
mCallbackManager.put(token->handle);
233+
}
232234
});
233235

234236
break;

0 commit comments

Comments
 (0)