I have a published app that has a need to keep the display on for an extended period of time. I use UIApplication.isIdleTimerDisabled
to control it, setting it true when I need to keep the display on, and setting it false when it's no longer needed.
Since the app is distributed through the Apple App Store, I get reports when crashes occur. I sometimes get a report that points to a crash at a line where I call UIApplication.shared.isIdleTimerDisabled = false
, i.e., where I'm restoring the normal state of affairs after the screen has been on for a while. Below is a screen shot of the stack trace.
I'm unable to reproduce the problem on my own. There are thousands of users who have downloaded and tried the program, and I only get one or two crash reports a week, so the problem must arise from some infrequently-occuring set of conditions. The crash reports come from a variety of iPhones and iPads running iOS 13 and 14.
Any ideas?