Android Question WebView Locks Up

canalrun

Well-Known Member
Licensed User
I have an app that I've been using for years. It's basically a list of webpages that I can cycle through by pressing a button and display one by one in a WebView. Sometimes I can cycle through the entire list without a problem. Other times a webpage will lock up while is displaying and I am forced to exit my application, go into settings and Force Stop the app, then reopen the application. The app then works properly or hangs up again after another couple pages.

I've been watching the app closely for the past couple weeks. Each time it hangs it seems as though it's in the middle of rendering one of the ads. It seems as though it's in an endless loop during rendering or maybe waiting for data from the ad source.

If I just exit the app, Android keeps it running in the background, and when I reopen the app it's still hung.

If I exit the app, Force Stop, then reopen the app, it works properly.

I've been racking my brain how to solve this problem. I don't think there's any way to Force Stop an app from within itself or to force an app to stop when you exit. I don't think there is any way to reset the WebView. I have tried someone's suggestion of using the Chrome Client – did not solve the problem.

Can anyone suggest anything I could try to solve this problem?

Thanks,
Barry.
 

DonManfred

Expert
Licensed User
Can anyone suggest anything I could try to solve this problem?
How? You are giving exactly ZERO informations on what you are doing and how.

Maybe the problem ist the the website you are showing which freezes.

Try to reproduce it in a small project and upload the project.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Thanks, but I'm really not doing anything.
I have a database of URLs, a Next button, a Prev button, and a WebView.
I do a LoadURL in the WebView of the URL loaded from the database.
If I hit the Next button, I load the next URL from the database and display it in the WebView.

When the WebView hangs I can see the light gray outline where one of the ads will be. If I wait for the ad it will never entirely complete loading. At this point swipe-scrolling on the page stops working and I cannot proceed to the next or previous pages. If I exit the app, Force Stop, then reopen the app, everything works again. If I just exit the app, then reopen, the WebView remains hung.

Sometimes I get through the entire database of URLs without a problem. Other times it hangs on almost every URL. I've noticed when it hangs the banner ad that's being displayed on the top does not complete (just shows a light gray outline). Doing a Google search I see a lot of people have problems with the WebView not rendering pages.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Thanks.

It's strange. I can tell my app is still running. If I press on the Prev or Next buttons I can see, via log messages, that the LoadURL statements with the correct URL are executed, but the webview does not respond. If I try to reload the current page, again, the webview does not respond.

It seems just like some thread of the webview is stuck in an endless loop trying to render the ad partially showing at the top. If I wait for a minute or two the Android error "App not Responding" never shows up.

The only thing I found that consistently works is to exit my app, do an app Force Stop from settings, then reenter my app. Whatever page was last selected now loads properly.

I guess I'm hoping there is a way to accomplish essentially the same thing – somehow force stop my app or somehow tell the webview to stop whatever it's doing.

I've issued the webview StopLoading command, but that does not do anything (supports my guess that the webview is not responding and stuck in an endless loop).

This app was written more than five years ago. It's always occasionally "hung", but that used to happen about once per month – so I just quit the app and came back the next day. Recently it hangs almost every day or on almost every page, but not always every page and not always the same page. The problem seems to be webpage data dependent – a certain type of ad displayed as the topmost webpage banner ad.

I've even tried to think of a way to strip the ads from the loading webpage, but looking at the HTML source, that would be difficult.
 
Last edited:
Upvote 0
Top