Skip to content

Conversation

@sanjaysargam
Copy link
Member

@sanjaysargam sanjaysargam commented Nov 23, 2025

Purpose / Description

RemoveAccountFragment was crashing on open because SafeWebViewLayout requires the host to implement OnWebViewRecreatedListener

Fixes

Approach

Implement listener and reinitialize WebView when recreated to avoid fragment crash

How Has This Been Tested?

Physical Device (Redmi 9 Pro 5G)

  • Triggered a forced WebView crash using chrome://crash after a 2-second delay
  • Confirmed onRenderProcessGone is called and the WebView is destroyed + recreated correctly.
  • Verified the fragment receives onWebViewRecreated and reloads the original URL.
  • Ensured the app stays stable with no crashes.
  • Added Timber logs to trace the full recovery flow.
image

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@BrayanDSO BrayanDSO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How Has This Been Tested?
Physical Device (Redmi)

this isn't a description of how has this been tested.

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Nov 23, 2025
@sanjaysargam sanjaysargam added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Nov 23, 2025
@BrayanDSO
Copy link
Member

Based on the video, I assume that you just opened the fragment and probably didn't understand the issue.

The fragment opens correctly even without this change. This is a onRenderProcessGone issue.

And you aren't properly implementing onWebViewRecreatedListener. The webview isn't configured correctly on it

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Nov 23, 2025
@BrayanDSO BrayanDSO marked this pull request as draft November 23, 2025 11:59
@sanjaysargam
Copy link
Member Author

The fragment opens correctly even without this change

It was crashing in debug apk

@david-allison
Copy link
Member

david-allison commented Nov 23, 2025

In a real crash, the WebView process is dead (either due to a bug, or via the OOM-killer) and the called code likely won't reinitialize the new WebView in the same way that the standard onCreate flow did

running loadUrl("chrome://crash") after a delay() gets you close enough to figure out how the WebView handles the issue when onRenderProcessGone is called


Aside: we should document this

@sanjaysargam sanjaysargam added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Nov 25, 2025
@sanjaysargam sanjaysargam marked this pull request as ready for review November 25, 2025 03:02
}

@Deprecated(
"Deprecated in java, still needed for API 23",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minSdk is now 24, so no need to keep this

@BrayanDSO BrayanDSO added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Nov 25, 2025
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

@david-allison david-allison added this pull request to the merge queue Nov 25, 2025
Merged via the queue into ankidroid:main with commit 7dc88ef Nov 25, 2025
15 checks passed
@github-actions github-actions bot removed the Needs Second Approval Has one approval, one more approval to merge label Nov 25, 2025
@github-actions github-actions bot added this to the 2.23 release milestone Nov 25, 2025
@david-allison
Copy link
Member

Important

We are trialling an increase to Open Collective payments, invoices submitted more than two weeks after the date you receive this message may not be eligible for this increase.

Hi there @sanjaysargam! This is the OpenCollective Notice for PRs merged from 2025-11-01 through 2025-11-30

If you are interested in compensation for this work, the process with details is here: https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid

We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month

Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding.

Thanks!

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.

[BUG] 'RemoveAccountFragment' crashes on open: must implement OnWebViewRecreatedListener

3 participants