Skip to content

fix(webview): hide progress bar on main-frame load errors#36

Open
jim-daf wants to merge 1 commit into
lloydtorres:masterfrom
jim-daf:fix-progressbar-onreceivederror
Open

fix(webview): hide progress bar on main-frame load errors#36
jim-daf wants to merge 1 commit into
lloydtorres:masterfrom
jim-daf:fix-progressbar-onreceivederror

Conversation

@jim-daf

@jim-daf jim-daf commented May 15, 2026

Copy link
Copy Markdown

Closes #35.

ProgressBarWebViewClient shows the progress bar on onPageStarted and hides it on onPageFinished. On some failure modes the WebView reports the failure through onReceivedError and skips onPageFinished, so the spinner stays visible over a blank WebRegisterActivity / PrivacyPolicyActivity. The user has no way to know the page never loaded.

Add a main-frame-only onReceivedError override that hides the progress bar too:

@Override
public void onReceivedError(WebView view, WebResourceRequest request,
                            WebResourceError error) {
    super.onReceivedError(view, request, error);
    if (request != null && request.isForMainFrame()) {
        mProgressBar.setVisibility(View.GONE);
    }
}

isForMainFrame keeps a single blocked sub-resource from hiding the spinner while the main load is still running. No callers of the client are affected.

ProgressBarWebViewClient shows the spinner on onPageStarted and hides
it on onPageFinished. On some failure modes the WebView reports the
failure through onReceivedError and skips onPageFinished, so the
spinner stays visible over a blank WebRegisterActivity /
PrivacyPolicyActivity. The user has no way to know the page never
loaded.

Add a main-frame-only onReceivedError override that hides the
progress bar too. isForMainFrame keeps a blocked sub-resource from
hiding the spinner while the main load is still running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProgressBarWebViewClient leaves the spinner up forever when a load fails with onReceivedError

1 participant