Skip to content

Commit

Permalink
REGRESSION (iOS 17 Beta): The call is not unmuted automatically after…
Browse files Browse the repository at this point in the history
… the use of Siri in the middle of the WebRTC call, sometimes incoming audio is lost

https://bugs.webkit.org/show_bug.cgi?id=259368
rdar://112636992

Reviewed by Eric Carlson.

WebProcess might want to try active its audio session when being interrupted.
In case GPUProcess tells it succeeded activating, it will uninterrupt and restart capturing microphone.

RemoteAudioSessionProxyManager::tryToSetActiveForProcess may return true to activation even though the underlying shared session was not properly activated.
This happens in case there is one RemoteAudioSessionProxy which is active but interrupted.
In that case, RemoteAudioSessionProxyManager::tryToSetActiveForProcess would think everything is fine.

To prevent this, RemoteAudioSessionProxy is now tracking whether it is interrupted or not.
If it is active but interrupted, RemoteAudioSessionProxyManager will not consider it is actually active and will try to activate the underlying audio session.
If activation succeeds, uninterruption will follow.
If activation fails, uninterruption will be further delayed.

Manually tested.

* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp:
* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h:
(WebKit::RemoteAudioSessionProxy::isInterrupted const):
* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
(WebKit::RemoteAudioSessionProxyManager::tryToSetActiveForProcess):

Canonical link: https://commits.webkit.org/266293@main
  • Loading branch information
youennf committed Jul 25, 2023
1 parent 4562311 commit 727f9c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ void RemoteAudioSessionProxy::configurationChanged()

void RemoteAudioSessionProxy::beginInterruption()
{
m_isInterrupted = true;
connection().send(Messages::RemoteAudioSession::BeginInterruptionRemote(), { });
}

void RemoteAudioSessionProxy::endInterruption(AudioSession::MayResume mayResume)
{
m_isInterrupted = false;
connection().send(Messages::RemoteAudioSession::EndInterruptionRemote(mayResume), { });
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class RemoteAudioSessionProxy
WebCore::RouteSharingPolicy routeSharingPolicy() const { return m_routeSharingPolicy; }
size_t preferredBufferSize() const { return m_preferredBufferSize; }
bool isActive() const { return m_active; }
bool isInterrupted() const { return m_isInterrupted; }

void configurationChanged();
void beginInterruption();
Expand Down Expand Up @@ -93,6 +94,7 @@ class RemoteAudioSessionProxy
WebCore::RouteSharingPolicy m_routeSharingPolicy { WebCore::RouteSharingPolicy::Default };
size_t m_preferredBufferSize { 0 };
bool m_active { false };
bool m_isInterrupted { false };
bool m_isPlayingToBluetoothOverrideChanged { false };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool RemoteAudioSessionProxyManager::tryToSetActiveForProcess(RemoteAudioSession

size_t activeProxyCount { 0 };
for (auto& otherProxy : m_proxies) {
if (otherProxy.isActive())
if (otherProxy.isActive() && !otherProxy.isInterrupted())
++activeProxyCount;
}

Expand Down

0 comments on commit 727f9c1

Please sign in to comment.