Skip to content

Commit 7af398c

Browse files
davidsharpTitozzz
andauthored
fix(ios, macos): Suspend media playback when destroying WebView on iOS/macOS (#3234)
* Suspend media playback when destroying WebView on iOS/macOS * Fixes crash on iOS <15.0 and macOS <12.0 when pausing playback on dismount --------- Co-authored-by: Thibault Malbranche <thibault@brigad.co>
1 parent d02f575 commit 7af398c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

apple/RNCWebViewImpl.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ - (void)removeFromSuperview
569569
[_webView.configuration.userContentController removeScriptMessageHandlerForName:MessageHandlerName];
570570
[_webView removeObserver:self forKeyPath:@"estimatedProgress"];
571571
[_webView removeFromSuperview];
572+
if (@available(iOS 15.0, macOS 12.0, *)) {
573+
[_webView pauseAllMediaPlaybackWithCompletionHandler:nil];
574+
} else if (@available(iOS 14.5, macOS 11.3, *)) {
575+
[_webView suspendAllMediaPlayback:nil];
576+
}
572577
#if !TARGET_OS_OSX
573578
_webView.scrollView.delegate = nil;
574579
if (_menuItems) {

0 commit comments

Comments
 (0)