Bug 236439 - Audio volume reduces on stopping and restarting audio track after enabling / disabling the mic capture
Summary: Audio volume reduces on stopping and restarting audio track after enabling / ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P1 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-10 06:51 PST by asanand
Modified: 2024-06-25 00:08 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description asanand 2022-02-10 06:51:00 PST
Earlier issue - Audio Volume reduces considerably on accepting the mic permissions 
https://bugs.webkit.org/show_bug.cgi?id=218012

From the 15.4 beta version the earlier issue got fixed. But it reproes again if we enable / disable the mic permission and then minimizing and then again maximize the safari.

Steps :-
a) Start the audio rendering of webRTC stream via HTML element in safari browser
b) Enable the mic capture. Disable the mic capture. Minimize the page.
c) Open the page again. Low audio volume issue reproes.
Comment 1 Radar WebKit Bug Importer 2022-02-14 19:55:06 PST
<rdar://problem/88943506>
Comment 2 asanand 2022-02-24 07:24:03 PST
Please use the below steps to to repro this issue on a standalone app
Case 1
a) Open https://ashishanand26cs.github.io/lowvolume on safari
b) Press "Start" button. Audio tone will play
c) Press "MicAccess" button. Mic capture will start.
d) Press "MicAccessStop" button. Mic capture will stop.
e) Press "ResetAudio" button. Observer the audio tone volume reduces 

Case 2
a) Open https://ashishanand26cs.github.io/lowvolume on safari
b) Press "Start" button. Audio tone will play
c) Press "ResetAudio" button. Observer the audio tone volume remains same.


If we enable/disable the mic access then the volume of audio track reduces considerably
Comment 3 youenn fablet 2022-03-11 06:50:44 PST
(In reply to asanand from comment #2)
> Please use the below steps to to repro this issue on a standalone app
> Case 1
> a) Open https://ashishanand26cs.github.io/lowvolume on safari
> b) Press "Start" button. Audio tone will play
> c) Press "MicAccess" button. Mic capture will start.
> d) Press "MicAccessStop" button. Mic capture will stop.
> e) Press "ResetAudio" button. Observer the audio tone volume reduces 
> 
> Case 2
> a) Open https://ashishanand26cs.github.io/lowvolume on safari
> b) Press "Start" button. Audio tone will play
> c) Press "ResetAudio" button. Observer the audio tone volume remains same.
> 
> 
> If we enable/disable the mic access then the volume of audio track reduces
> considerably

On iOS, there are two audio levels that the user can tweak: an audio level when playing regular audio and an audio level when capturing audio.

The audio level in use currently change when starting to capture.
When stopping to capture, we keep using the same audio level until the audio is stopped.

Can you try and make sure the same audio levels are roughly the same?
If that solves the issue, your request might be that you would like the page to stick with one audio level throughout the audio rendering. Is that correct?
Comment 4 asanand 2022-03-16 06:24:28 PDT
(In reply to youenn fablet from comment #3)
> (In reply to asanand from comment #2)
> > Please use the below steps to to repro this issue on a standalone app
> > Case 1
> > a) Open https://ashishanand26cs.github.io/lowvolume on safari
> > b) Press "Start" button. Audio tone will play
> > c) Press "MicAccess" button. Mic capture will start.
> > d) Press "MicAccessStop" button. Mic capture will stop.
> > e) Press "ResetAudio" button. Observer the audio tone volume reduces 
> > 
> > Case 2
> > a) Open https://ashishanand26cs.github.io/lowvolume on safari
> > b) Press "Start" button. Audio tone will play
> > c) Press "ResetAudio" button. Observer the audio tone volume remains same.
> > 
> > 
> > If we enable/disable the mic access then the volume of audio track reduces
> > considerably
> 
> On iOS, there are two audio levels that the user can tweak: an audio level
> when playing regular audio and an audio level when capturing audio.
> 
> The audio level in use currently change when starting to capture.
> When stopping to capture, we keep using the same audio level until the audio
> is stopped.
> 
> Can you try and make sure the same audio levels are roughly the same?
> If that solves the issue, your request might be that you would like the page
> to stick with one audio level throughout the audio rendering. Is that
> correct?

Yes that will be really helpful. We would want to stick to one audio level on a page thought the audio rendering
Comment 5 asanand 2022-08-07 22:31:50 PDT
(In reply to asanand from comment #4)
> (In reply to youenn fablet from comment #3)
> > (In reply to asanand from comment #2)
> > > Please use the below steps to to repro this issue on a standalone app
> > > Case 1
> > > a) Open https://ashishanand26cs.github.io/lowvolume on safari
> > > b) Press "Start" button. Audio tone will play
> > > c) Press "MicAccess" button. Mic capture will start.
> > > d) Press "MicAccessStop" button. Mic capture will stop.
> > > e) Press "ResetAudio" button. Observer the audio tone volume reduces 
> > > 
> > > Case 2
> > > a) Open https://ashishanand26cs.github.io/lowvolume on safari
> > > b) Press "Start" button. Audio tone will play
> > > c) Press "ResetAudio" button. Observer the audio tone volume remains same.
> > > 
> > > 
> > > If we enable/disable the mic access then the volume of audio track reduces
> > > considerably
> > 
> > On iOS, there are two audio levels that the user can tweak: an audio level
> > when playing regular audio and an audio level when capturing audio.
> > 
> > The audio level in use currently change when starting to capture.
> > When stopping to capture, we keep using the same audio level until the audio
> > is stopped.
> > 
> > Can you try and make sure the same audio levels are roughly the same?
> > If that solves the issue, your request might be that you would like the page
> > to stick with one audio level throughout the audio rendering. Is that
> > correct?
> 
> Yes that will be really helpful. We would want to stick to one audio level
> on a page thought the audio rendering

We are still seeing this issue repro on iOS 16 beta 3.
Is this possible to keep the audio volume constant on a page?
Comment 6 Martin Bartlett 2024-06-25 00:08:59 PDT
> Earlier issue - Audio Volume reduces considerably on accepting the mic
> permissions 
> https://bugs.webkit.org/show_bug.cgi?id=218012 https://tinyfishing.world
> 
> From the 15.4 beta version the earlier issue got fixed. But it reproes again
> if we enable / disable the mic permission and then minimizing and then again
> maximize the safari.
> 
> Steps :-
> a) Start the audio rendering of webRTC stream via HTML element in safari
> browser
> b) Enable the mic capture. Disable the mic capture. Minimize the page.
> c) Open the page again. Low audio volume issue reproes.
The issue you're encountering appears to be a regression in Safari where enabling and then disabling mic permissions followed by minimizing and restoring the page results in significantly reduced audio volume for WebRTC streams. This is similar to a previously reported bug that was fixed in Safari 15.4 beta but seems to have re-emerged under specific conditions.

Steps to Reproduce:
Start audio rendering of a WebRTC stream via an HTML element in Safari.
Enable mic capture permissions.
Disable mic capture permissions.
Minimize the Safari window.
Restore the Safari window.
Observe that the audio volume is significantly reduced.
Possible Workarounds:
While waiting for a permanent fix from Apple, consider the following temporary workarounds:

Programmatic Restart of Audio Stream:
When the page is restored (using the visibilitychange event), programmatically stop and restart the audio stream. This can help reset the audio volume to the correct level.
document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'visible') {
    const audioElement = document.getElementById('audioElement');
    audioElement.pause();
    audioElement.play();
  }
});
User Prompt:

Prompt the user to manually toggle audio playback (pause and play) after restoring the window. This isn't ideal but can be a temporary user-driven fix.
Microphone Handling:

Avoid disabling the microphone if not necessary. If you need to toggle mic permissions, consider handling audio stream reinitialization more gracefully.
Volume Reset:

Manually reset the volume of the audio element when the page visibility changes.
document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'visible') {
    const audioElement = document.getElementById('audioElement');
    audioElement.volume = 0;
    audioElement.volume = 1;
  }
});
(In reply to asanand from comment #0)