-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix unstable sound level #53449
Fix unstable sound level #53449
Conversation
b4776b5
to
2c91dcf
Compare
140860a
to
f98f9da
Compare
@@ -211,14 +209,13 @@ function BaseVideoPlayer({ | |||
setIsEnded(false); | |||
} | |||
|
|||
if (prevIsMutedRef.current && prevVolumeRef.current === 0 && !status.isMuted) { | |||
updateVolume(0.25); | |||
if (prevIsMuted.get() && volume.get() === 0 && !status.isMuted) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I thought I would be able to get rid of this part completely, however, in the full-screen mode mute states are not properly initialized on first startup, this fixes these lines now
34a46c8
to
bb836ca
Compare
@@ -90,7 +90,7 @@ function BaseVideoPlayer({ | |||
const isCurrentlyURLSet = currentlyPlayingURL === url; | |||
const isUploading = CONST.ATTACHMENT_LOCAL_URL_PREFIX.some((prefix) => url.startsWith(prefix)); | |||
const videoStateRef = useRef<AVPlaybackStatus | null>(null); | |||
const {updateVolume} = useVolumeContext(); | |||
const {updateVolume, lastNonZeroVolume, volume} = useVolumeContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eslint is failing here
currentVideoPlayerRef.current.setStatusAsync({volume: newVolume, isMuted: newVolume === 0}); | ||
currentVideoPlayerRef.current.setStatusAsync({ | ||
volume: newVolume, | ||
isMuted: newVolume === 0, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing was changed here, right? Let's revert
volume.set(newVolume); | ||
}, | ||
[currentVideoPlayerRef, volume], | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well, let's add the empty line back
const toggleMute = () => { | ||
if (volume.get() !== 0) { | ||
lastNonZeroVolume.set(volume.get()); | ||
} | ||
updateVolume(volume.get() === 0 ? lastNonZeroVolume.get() : 0); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this logic to the Volume context? Additionally, I strongly recommend adding a comment to clearly explain its purpose.
@@ -211,14 +210,15 @@ function BaseVideoPlayer({ | |||
setIsEnded(false); | |||
} | |||
|
|||
if (prevIsMutedRef.current && prevVolumeRef.current === 0 && !status.isMuted) { | |||
updateVolume(0.25); | |||
if (prevIsMuted.get() && prevVolume.get() === 0 && !status.isMuted) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment explaining why this logic is necessary
29e66fd
to
d8c55a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! LGTM
@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@hungvu193 Please check out the original PR that caused this issue. The idea was to implement it similarly to how youtube works, and remove the faulty code and refs completely |
Thanks for the context. I'll take a look |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-12-06.at.00.08.47.movAndroid: mWeb ChromeUploading mWeb.mov..... iOS: NativeIOS.moviOS: mWeb SafariScreen.Recording.2024-12-06.at.00.20.06.movMacOS: Chrome / SafariScreen.Recording.2024-12-05.at.23.58.59.movScreen.Recording.2024-11-17.at.18.20.31.movMacOS: DesktopDesk.mov |
We did not find an internal engineer to review this PR, trying to assign a random engineer to #52858 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/blimpich in version: 9.0.73-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.0.73-8 🚀
|
Explanation of Change
The logic responsible for proper mute and unmute functionality has been implemented, eliminating audio instability issues on mobile devices.
Fixed Issues
$ #52858
$
PROPOSAL:
Tests
Expected behavior:
The volume remains at the level it was set to.
Offline tests
unnecessary
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.native_2.mp4
Android: mWeb Chrome
android.web.mp4
iOS: Native
ios.native.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-12-05.at.08.53.23.mp4
MacOS: Desktop
desktop.mac_1.mp4