Skip to content

Timer not firing as expected(randomly) when application is put in background mode after scheduling it #9141

@harishchopra86

Description

@harishchopra86

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 7.1.2
  • Cross-platform modules: 7.1.0
  • Android Runtime: 7.0.1
  • iOS Runtime: 7.1.0
  • XCode Version: 12.3

Describe the bug
I am using Native Script Timer for implementing idle timeout in my project. It works fine when application is running in foreground mode. However when application is in background and phone is not being used timer does not fires.

Android behaviour:
Timer does not fires after the elapsed time when application is in background.

iOS behaviour:
I know timers does not fire in iOS when application is in background. But in this case timer is not firing when application comes to foreground after elapsed time.

To Reproduce

  1. Create a new timer in native script project scheduled to fire after 30 minutes
  2. Put application in background and do not use the phone during that time. Phone should be locked and not on charging mode
  3. Launch the application after 30 minutes.
  4. You will notice that timer had not fired.

Expected behavior
In Android timer should have fired after 30 minutes.
In iOS timer should have fired instantly when application comes to foreground anytime after 30 minutes.

Additional context

  • In steps to reproduce if you continue using other applications on the phone while this application is in background, then timer will fire as expected.
  • It works as expected while debugging and on simulator/emulator.
  • I tried scheduling timer with a native iOS project and it was working as expected which makes me believe that there is something at native script side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions