WebViewFragment.kt:48 is the in-app browser the user types or navigates a URL into so it can be picked for monitoring. The WebViewClient overrides onPageStarted to show the progress bar and onPageFinished to hide it, but there is no onReceivedError override:
webview.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
refreshBack(view)
updateUrl(url)
progress?.visibility = View.VISIBLE
super.onPageStarted(view, url, favicon)
}
override fun onPageFinished(view: WebView?, url: String?) {
refreshBack(view)
updateUrl(url)
progress?.visibility = View.GONE
super.onPageFinished(view, url)
}
}
When the user types something that fails to load (DNS error, certificate problem, offline, 4xx/5xx, etc.), onPageFinished still fires eventually but the WebView is left displaying a blank area with no indication of why the page did not show up. From the user's side it just looks like the app stopped working.
Suggested fix
Add an onReceivedError override that hides the progress bar and surfaces a short Toast with the failure reason. Gate it on request.isForMainFrame == true so every blocked sub-resource on a page does not also pop a Toast. Add a couple of strings (webview_load_failed, webview_load_failed_with_reason) so the message stays translatable.
A PR with that change is open at #61.
WebViewFragment.kt:48is the in-app browser the user types or navigates a URL into so it can be picked for monitoring. TheWebViewClientoverridesonPageStartedto show the progress bar andonPageFinishedto hide it, but there is noonReceivedErroroverride:When the user types something that fails to load (DNS error, certificate problem, offline, 4xx/5xx, etc.),
onPageFinishedstill fires eventually but the WebView is left displaying a blank area with no indication of why the page did not show up. From the user's side it just looks like the app stopped working.Suggested fix
Add an
onReceivedErroroverride that hides the progress bar and surfaces a short Toast with the failure reason. Gate it onrequest.isForMainFrame == trueso every blocked sub-resource on a page does not also pop a Toast. Add a couple of strings (webview_load_failed,webview_load_failed_with_reason) so the message stays translatable.A PR with that change is open at #61.