Skip to content

[FIX] DidNotStartInTimeException & DidNotStopInTimeException#377

Open
meliksahcakirr wants to merge 1 commit intoDev-hwang:masterfrom
meliksahcakirr:development
Open

[FIX] DidNotStartInTimeException & DidNotStopInTimeException#377
meliksahcakirr wants to merge 1 commit intoDev-hwang:masterfrom
meliksahcakirr:development

Conversation

@meliksahcakirr
Copy link

Issue

Both update() and stop() operations call isRunningService() at the beginning of the function.
If the service is already running, we know that it has already been started.

However, at the end of these functions ContextCompat.startForegroundService(context, nIntent) is still called. This re-triggers the foreground service start contract, even though the service is already running.

Proposed Change

Instead of calling startForegroundService, the code should call startService when the service is already running.

This avoids re-triggering the internal startForeground() requirement that applies when startForegroundService is used.

Motivation

In our applications we frequently observe the following exceptions:

  • ForegroundServiceDidNotStartInTime
  • ForegroundServiceDidNotStopInTime

After applying this change on our side (using startService when the service is already running), these exceptions disappeared completely.

Additional Context

We initially expected that overriding the timeOut() function would eliminate the ForegroundServiceDidNotStopInTime error. However, we continued to observe it until applying the change proposed in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant