Setting a timer for a long period of time

Please provide the following:

  1. SDK Version: sdk-40.0.1
  2. Platforms(Android/iOS/web/all): all
  3. Add the appropriate “Tag” based on what Expo library you have a question on. Setting a timer for a long period of time

Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See Add support for AlarmManager in Timing to allow proper handling of long timers · Issue #12981 · facebook/react-native · GitHub for more info.
(Saw setTimeout with duration 600000ms)

Hey @dent, can you clarify exactly what you are meaning to bring to our attention? Specifically, what within Expo.

Cheers,
Adam

1 Like

@adamjnav I ran into this warning when trying to use setInterval() to schedule OTA periodic update checks for an app. When I got the warning I instead changed it to keep track of when the last check was done and then when the user clicked on one of the buttons, compare the current time with the time of the last update to see if enough time had passed since the previous check. I then execute the “real” onPress handler. That worked well enough for my simple app. I imagine this could get messy in a more complex app :sweat_smile:

I suspect having an OTA updates state machine that you can send events to and another state machine for dealing with button presses etc. would make it tidier.

@dent your message is not very clear at all. You have just pasted in an error message without saying it was an error message. If I hadn’t seen it myself before I would have thought it was written by you.

You have not asked any question or given us any indication of what you’re doing that might have resulted in the error.

If you want us to help you, please provide more context. But see the following message (and maybe the rest of the thread) for some more info:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.