Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ability to stop all extractors #119

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

dprevost-LMI
Copy link
Contributor

@dprevost-LMI dprevost-LMI commented Oct 20, 2024

In a scenario where we want to use the audio player to load several audio messages for different conversations and where navigation between conversations is required only to show one conversation at a time, we need an efficient way to load the audio message but also to cancel nearly everything if we switch to another conversation.

In the above scenario, when navigating away from all those audio players being played or having their waveform extracted, we need to stop them. Otherwise, opening more and more conversations in a short period will bust resources (promises, players, extractors).

This PR provides a new stopAllWaveFormExtractors, which, when called, stops all waveform extraction to free resources for the following conversation that will be loaded. Combined with stopAllPlayers, the new stopPlayersAndExtractors in the useAudioPlayer hook provides a way to stop everything around the audio players to ensure that no more resources are spent on the unmount screen.

The new Stop all players and extractos option:
Screenshot 2024-11-16 at 8 27 04 AM

Other:

  • Now, the whole audio player HashMap is cleared to stop growing forever without removing keys.
  • The CountDownLatch was removed since it was not used anywhere.
  • The delete recording and stop all are hidden under the SIMFORM header click to keep first impression better
  • The example app image colour space was changed from Gray to RGB, which was causing the tintColor issue not to work
  • I removed the loading indicator on the stop button and kept it only on the play button. Now it looks better with fewer loading icons spinning everywhere
image

@dprevost-LMI dprevost-LMI changed the title feat: stop all extractors feat: ability to stop all extractors Oct 20, 2024
Copy link
Contributor

@kuldip-simform kuldip-simform left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dprevost-LMI Can you add these new methods in readme docs as well?

example/src/App.tsx Outdated Show resolved Hide resolved
example/src/App.tsx Outdated Show resolved Hide resolved
example/src/App.tsx Show resolved Hide resolved
@kuldip-simform kuldip-simform linked an issue Oct 23, 2024 that may be closed by this pull request
@dprevost-LMI dprevost-LMI marked this pull request as draft November 9, 2024 12:42
@dprevost-LMI dprevost-LMI force-pushed the allow-to-stop-all-extractors branch 3 times, most recently from 1965941 to 891a7c5 Compare November 9, 2024 13:05
@dprevost-LMI dprevost-LMI force-pushed the allow-to-stop-all-extractors branch from 97cf9f8 to bb8f68b Compare November 16, 2024 12:31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change cannot be seen since I used a tool to change the space colour from Gray to RBG, this. fixed the tintColor problem on iOS

@dprevost-LMI
Copy link
Contributor Author

Waiting on #123 merge to fix the player button s issue when clicking stop all

@dprevost-LMI dprevost-LMI force-pushed the allow-to-stop-all-extractors branch from 708eeb3 to 1f3a0bf Compare November 18, 2024 12:23
@dprevost-LMI
Copy link
Contributor Author

Now waiting on #136 since some promise rejections are missing to thoroughly test the player after stopping everything!

chore: wrong AudioWaveform import in App.tsx + delete recording button

fix: wrong path

chore: log error only when not stop by everything

fix: missing promise.resolve

chore: review `handleStopEverything` and `handleDeleteRecordings`

fix: promises resolve too soon because of the stop everything changes

fix: all error pass to onError should be an Error instance, not a string

fix: move stopEverything in JS + clear all arrays for less leak

chore: stop recorder also + remove logPromise

chore: remove unneeded changes

chore: expose `stopAllWaveFormExtractors`

fix: better white delete icon

chore: remove delete recodings

fix: review array item handling since we clear the arrays

chore: fix doc

feat: make stopAllWaveFormExtractors work in iOS + remove stopRecording

fix: remove everything from the player array to not increase forever

chore: small renaming
@dprevost-LMI dprevost-LMI force-pushed the allow-to-stop-all-extractors branch from 1f3a0bf to 908217e Compare November 19, 2024 11:41
@dprevost-LMI
Copy link
Contributor Author

Rebased and retested on Android and iOS
Note: The error Possible unhandled seen is not caused by this PR but by the stopAllPlayers already existing that I point out and where we made a quick fix in this PR to have the player "auto-fix" when clicking play or seek

Screen.Recording.2024-11-19.at.6.50.32.AM.mov

@dprevost-LMI dprevost-LMI marked this pull request as ready for review November 19, 2024 11:57
@dprevost-LMI
Copy link
Contributor Author

@kuldip-simform, when you have a minute, this PR is ready to be approved & merged!

@dprevost-LMI
Copy link
Contributor Author

Hey, I'm just checking if there are still some chances to merge this one; otherwise, I will just close it!

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.

[FEATURE] Stop all extractors to free resources
2 participants