Skip to content

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?

@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!

@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!

@alikazemkhanloo
Copy link

Hey, thank you all for your efforts. Is this feature ready to be merged? I guess all the requested changes were done.

@dprevost-LMI
Copy link
Contributor Author

🤔 I have just realized that the below is still missing

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

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 3affc3c to 201cd50 Compare January 13, 2025 23:31
chore: add missing doc as requested
@dprevost-LMI dprevost-LMI force-pushed the allow-to-stop-all-extractors branch from 201cd50 to efc65a3 Compare January 13, 2025 23:31
@dprevost-LMI
Copy link
Contributor Author

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

@kuldip-simform, I have added the missing doc. Can we move forward and merge? Thank you!

@dprevost-LMI
Copy link
Contributor Author

@kuldip-simform @mukesh-simform Are you still open to my contribution, or should I stop trying to reach you guys?

@mukesh-simform
Copy link
Collaborator

@dprevost-LMI we truly appreciate your contributions—they have been invaluable in enhancing the library, and we absolutely welcome and encourage your input. We've been working on testing other enhancements and planning new releases soon. Please feel free to continue contributing and raising PRs, we'd be happy to review, approve, and merge any improvements or bug fixes!

@mukesh-simform
Copy link
Collaborator

We will conduct further testing on this open PR and proceed with merging it accordingly. If any changes are required, we will provide feedback. otherwise, it will be included in the upcoming release!

@dprevost-LMI
Copy link
Contributor Author

Thanks for your prompt response! I look forward to your feedback on whether any changes are required before merging!

@kuldip-simform
Copy link
Contributor

kuldip-simform commented Feb 11, 2025

@dprevost-LMI This looks great. Thank you for adding this feature.
Can you please update this branch with the latest develop branch, as we have just released version 2.1.3, so we can test with all the new features and make sure it is compatible with the latest changes, then we can move forward.

Also If we can add stop all player and extractors button below delete button that would be ideal.

Simulator Screenshot - iPhone 16 Pro - 2025-02-11 at 11 37 12

@dprevost-LMI
Copy link
Contributor Author

@kuldip-simform, it is rebased, and by clicking the SIMFORM header, the two options should appear/disappear

Screen.Recording.2025-02-12.at.8.12.39.AM.mov

@mukesh-simform mukesh-simform merged commit 33fc88e into SimformSolutionsPvtLtd:develop Feb 13, 2025
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

4 participants