File tree Expand file tree Collapse file tree
AnkiDroid/src/main/java/com/ichi2/anki Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,6 +146,12 @@ abstract class CardViewerFragment(
146146
147147 protected open fun onCreateWebChromeClient () = CardViewerWebChromeClient ()
148148
149+ /* *
150+ * Reconfigures the [WebView] after a render process crash by calling [setupWebView].
151+ *
152+ * Subclasses that override this method must call `super.onWebViewRecreated(webView)`,
153+ * as the base implementation reapplies all clients, settings, and content.
154+ */
149155 override fun onWebViewRecreated (webView : WebView ) {
150156 setupWebView(null )
151157 }
Original file line number Diff line number Diff line change @@ -217,6 +217,26 @@ open class SafeWebViewLayout :
217217 }
218218}
219219
220+ /* *
221+ * Listener for [SafeWebViewLayout.onRenderProcessGone], called after the internal [WebView] is
222+ * replaced due to a render process crash or the system killing it to free memory.
223+ *
224+ * Any [Fragment] containing a [SafeWebViewLayout] **must** implement this interface. In debug builds,
225+ * a missing implementation will throw at [SafeWebViewLayout.onAttachedToWindow()]
226+ *
227+ * @see SafeWebViewLayout.onRenderProcessGone
228+ */
220229fun interface OnWebViewRecreatedListener {
230+ /* *
231+ * Reconfigures a [WebView] after [SafeWebViewLayout.onRenderProcessGone] has replaced
232+ * the old instance. Implementations must reapply all clients, settings and content
233+ * that were configured on the original [WebView], as [SafeWebViewLayout] only handles
234+ * the structural replacement and cannot reapply app level configuration.
235+ *
236+ * To manually trigger this path, call `webViewLayout.loadUrl("chrome://crash")`.
237+ * Automated testing requires an instrumented test; a unit test is not sufficient.
238+ *
239+ * @param webView the new [WebView], already attached to [SafeWebViewLayout]
240+ */
221241 fun onWebViewRecreated (webView : WebView )
222242}
You can’t perform that action at this time.
0 commit comments