cordova-plugin-media
cordova-plugin-media copied to clipboard
fix(ios): New method allowing to disable automated memory release on memoryWarning (CB-11409)
Platforms affected
iOS
What does this PR do?
It is adding a method allowing the user to disable (and re-enable) the automated resource releasing when a memory warning is received on iOS. Why? Because user may want to handle memory warnings by himself (such as releasing other less important resource first).
This method is static, on the class:
Media.shouldReleaseOnMemoryWarning(false);
// Here comes custom code to handle memoryWarnings
What testing has been done on this change?
- Played multiple (non streaming) audio files after having disabled the auto-release and while having some heavy memory process running, until a memoryWarning is received: audio continue to play.
- Played multiple (non streaming) audio files with the auto-release enabled and while having some heavy memory process running, until a memoryWarning is received: audio stops.
Ran the integrated tests. Before doing any change (version 2.3.1-dev) the result was:

After the change the result is exactly the same:

All tests was made with an iPad2 on iOS8.4.
Checklist
- [x] ICLA has been signed and submitted to [email protected].
- [x] Reported an issue in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ ] Added automated test coverage as appropriate for this change.
About the last point: tests will come as soon as possible, meanwhile please have a look at the code and review it! Thank you.
Cordova CI Build has one or more failures.
Commit - Link Dashboard - Link
| Builder Name | Console Output | Test Report | Device Logs |
|---|---|---|---|
| Windows 8.1 Store | Link | Link | Link |
| Windows 10 Store | Link | Link | Link |
| Windows 8.1 Phone | Link | Link | Link |
| iOS | Link | Link | Link |
| Android | Link | Link | Link |
What about this? Would it be possible to have a comment or an opinion?
Hi,
Just dropping by to say that the current behaviour (stopping the music as soon as a memory warning is received) poses an issue for us as well. Having the music stop is the very last thing we want to do.
Please check if PullRequest #120 will resolve your issue. I think, the user should not be involved in this issue, especially as it only affects iOS. Releasing playing/recording media is unnecessary in the first place.
Hey @tbrebant, seems there is a merge conflict now. Could you please take care of this? Thanks.
The issue addressed in this PR was fixed by: https://github.com/apache/cordova-plugin-media/pull/120 This PR can be dropped.
Thanks for the feedback @katzlbt.
If I understand #120 correctly, that PR changed the way the memory pressure warning is handled to only drop non playing sounds. This PR would have added an option to disable the dropping completely - correct? There is no possible other need for the functionality contained in this PR?
(Sorry if my question are a bit basic here, I am not super accustomed to this plugin and iOS dev in general)
Yes your assessment is correct, and there is no other functionality contained in the PR. The problem addressed by this PR is already fixed.