Skip to content

Ensure the webview content is always rendered when fragment is resumed #5987

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -891,19 +891,31 @@ class BrowserTabFragment :
Timber.d("Resuming webview: $tabId")
webView?.let { webView ->
if (webView.isShown) {
webView.ensureVisible()
webView.onResume()
} else if (swipingTabsFeature.isEnabled) {
// Sometimes the tab is brought back from the background but the WebView is not visible yet due to
// ViewPager page change delay; this fixes an issue when a tab was blank.
// Sometimes a tab is brought back from the background but the WebView is not shown yet due to
// ViewPager page change delay; this makes sure the WebView is resumed when it is shown.
webView.post {
if (webView.isShown) {
webView.ensureVisible()
webView.onResume()
}
}
} else {
Timber.d("WebView is not shown, not resuming")
}
}
}

// This is a hack to make sure the WebView content is always rendered when the fragment is resumed
private fun DuckDuckGoWebView.ensureVisible() = postDelayed(100) {
if (swipingTabsFeature.isEnabled) {
scrollBy(0, 1)
scrollBy(0, -1)
}
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
omnibar = Omnibar(settingsDataStore.omnibarPosition, visualDesignExperimentDataStore.getOmnibarType(), binding)
Expand Down
Loading