apache / apache/cordova-plugin-media
mediaStatus and mediaError callbacks not always firing when Android activity is killed
- Dominant language
- JavaScript
- Stars
- 391
- Forks
- 762
- PR merge metrics
- No merged PRs in 30d
Description
When killing an app on Android (by swiping the activity to dismiss it), the plugin seems to behave inconsistently. I've noticed one of two things happens:
A: The expected scenario: both the mediaStatus and mediaError get called. This is ideal, since the media status is likely to go from playing (2) or paused (3), to stopped (4) — and being able to execute code based on these events is useful. I agree with @wspresto though on #194 that it would be nice to distinguish between "normal" stop events, and stop events triggered by the operating system killing the activity.
B: The actual scenario: neither the registered mediaStatus nor mediaError callbacks get called.
This is happening fairly inconsistently. It seems to work as expected if you start playing something, pause it, and immediately kill the activity. However, it tends to break if you pause the media, then open a bunch of other apps, lock/unlock the screens a few time, and then kill the activity. Even then, it's only breaking around 25% of the time for me.
I've tested this on an both Android 7.2 and Android 8.1 devices, but I'd expect it's happening elsewhere as well. I'm wondering if the plugin is even getting notified that the activity was destroyed in the onActivityDestroyed handler in the broken scenario.
Happy to provide additional information as needed.
Contributor guide
Research direction
Start at the Android activity lifecycle entry point, especially the onActivityDestroyed handler, and reproduce the issue on the Android 7.2 and 8.1 devices described. Trace whether activity destruction reaches the media callbacks in the intermittent case; done means the expected mediaStatus and mediaError behavior is consistent after the activity is killed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100