markdown-webview
markdown-webview copied to clipboard
WKWebView: Fix Blank Screen and Prevent Memory Leaks
-
Use removeScriptMessageHandlers to prevent memory leaks.
-
Recreate the web view when it turns blank.
Reference: https://nevermeant.dev/handling-blank-wkwebviews/
We avoid using a timer-based solution since it's resource-intensive. Instead, we've observed that blank issues typically occur when the app is restored from the background. Therefore, a one-time check is performed during background restoration.