turbolinks / turbolinks-ios

Native iOS adapter for building hybrid apps with Turbolinks 5
MIT License
881 stars 92 forks source link

Blank webview after backgrounding #65

Closed michiels closed 8 years ago

michiels commented 8 years ago

I am seeing behavior that Turbolinks webviews get cleared after backgrounding the app or not using it for a while. The navbar still shows, but the webview is just blank. Pull to refresh still works and after reloading via pull to refresh, the web content is visible again.

Is this some issue with memory management? Any way to prevent this or reload webviews after they are "cleared"?

joshuajansen commented 8 years ago

I'm experiencing this issue with my (UITabBar) app as well!

zachwaugh commented 8 years ago

Without seeing a reproducible case, I can't say for sure what the issue is, but it sounds like the web view process is getting killed. This can happen since the web view runs in a different process from your app. There is a WKNavigationDelegate method for this case - https://developer.apple.com/reference/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi. In Basecamp, we issue a reload whenever it happens:

    func webViewWebContentProcessDidTerminate(webView: WKWebView) {
        turbolinksSession.reload()
    }

Try adding that and see if it helps.

michiels commented 8 years ago

@zachwaugh Many thanks. Let me try this out! It sounds plausible.

danielnord commented 7 years ago

@michiels Did it work? Where can I place this code block within my own classes? I don't understand how I can override WKWebViewDelegate within my own classes without disturbing the Turbolinks library.

RNZ01 commented 5 years ago

@michiels Did it work? Where can I place this code block within my own classes? I don't understand how I can override WKWebViewDelegate within my own classes without disturbing the Turbolinks library.

Same question ...