Hi, I work on a game for iOS and the framerate decreases progressively when the debugger is attached. Running it for 2mins, it went from 30 to 1 FPS while rendering a simple static scene.
I narrowed it down to a call to dispatch_async_f which takes longer to execute over time.
clock_t t1 = clock();
dispatch_async_f(queue, context, function);
clock_t t2 = clock();
double duration = (double)(t2 -t1)/(double)CLOCKS_PER_SEC;
Dodumentation says dispatch_async_f is supposed to return immediatly. So what could explain duration to increases in debug? Am i measuring this incorrectly?
The game is written in mixed C++ and ObjC. It uses Metal as graphic API and GCD for dispatching jobs. I have Xcode 13.4.1 and test on an iPhone 13 Pro with iOS 15.7.
Thanks.
Is the game doing something wrong to cause this?
No.
This feature is super cool. It allows various tools, including the debugger, to backtrace across Dispatch calls. So, if you stop in the debugger you’ll get the backtrace of the thread up to the point where the block was run by Dispatch and then it’ll show you the backtrace of the thread that enqueued the block on the queue and so on. If you disable this feature, you lose everything except the initial backtrace.
Now, this doesn’t come for free. There’s always a cost to this feature. However, I’m surprised that the cost is steadily increasing as your app runs. If you can distill this down into a small test project that demos the problem, file a bug with that project so that the tools team can investigate.
Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"