delight-im / Android-AdvancedWebView

Enhanced WebView component for Android that works as intended out of the box
MIT License
2.39k stars 574 forks source link

Why does the WebView call resumeTimers/pauseTimers ? #251

Open ilandbt opened 5 years ago

ilandbt commented 5 years ago

Hey, Hey why do you call resumeTimers /pauseTimers in onResume/onPause ? These functions affect all WebViews in the app.

You can see In onPause comment. https://android.googlesource.com/platform/frameworks/base/+/a5408e6/core/java/android/webkit/WebView.java#1140

That calling webView.onPause should be enough.

This affects all webViews that don't call these functions.

Thanks

ocram commented 5 years ago

Thanks for your question!

Let’s just see what the official documentation says about this:

So that’s why it had been implemented.

In addition, onPause had not been available initially, though it has now been available for quite some time.

Most use cases have a single WebView (at a time), where this solution works perfectly.

If we want to remove the calls, we should do a thorough investigation regarding its effects. Alternatively, we could allow for these calls to be disabled (while still enabling them by default).

ilandbt commented 5 years ago

Thanks for the fast response. My issue with this is that you change a global state with a specific instance.

I'n my case i have a fragment with AdvancedWebViewthat can open a new Fragment with the native WebView. So the Native WebViewstops working in this scenario.

As you added from the official documentation - This can be useful if the application has been paused.

I would call pauseTimers() only in this scenario. not when the fragmentis paused.

I think the removal of these functions should be investigated but for now i think a disable function is a good idea.

Thanks again