Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #3760 - Fix Brave-Talk and Youtube not working when tabs are swit…
Browse files Browse the repository at this point in the history
…ched (#3925)
  • Loading branch information
Brandon-T authored Jul 15, 2021
1 parent 224602e commit c3c3b3d
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,30 @@ extension BrowserViewController: TabManagerDelegate {
wv.accessibilityLabel = nil
wv.accessibilityElementsHidden = true
wv.accessibilityIdentifier = nil
wv.removeFromSuperview()

// Firefox code removed webview from superview,
// but this causes PDFs to stop rendering,
// audio and video to stop playing, etc..
for tab in tabManager.allTabs where tab != selected {
if let webView = tab.webView {
#if swift(>=5.4)
if #available(iOS 14.5, *) {
webView.requestMediaPlaybackState { state in
if state == .playing {
webView.isHidden = true
webView.alpha = 0.0
} else {
webView.removeFromSuperview()
}
}
} else {
webView.removeFromSuperview()
}
#else
webView.removeFromSuperview()
#endif
}
}
}

toolbar?.setSearchButtonState(url: selected?.url)
Expand All @@ -2125,12 +2148,16 @@ extension BrowserViewController: TabManagerDelegate {

scrollController.tab = selected
webViewContainer.addSubview(webView)
webView.snp.makeConstraints { make in
webView.snp.remakeConstraints { make in
make.left.right.top.bottom.equalTo(self.webViewContainer)
}
webView.accessibilityLabel = Strings.webContentAccessibilityLabel
webView.accessibilityIdentifier = "contentView"
webView.accessibilityElementsHidden = false

// Restore WebView visibility state
webView.isHidden = false
webView.alpha = 1.0

if webView.url == nil {
// The web view can go gray if it was zombified due to memory pressure.
Expand Down

0 comments on commit c3c3b3d

Please sign in to comment.