简体   繁体   中英

Does a Web Worker run on the main ui android thread or a separate thread?

I have an OLD application for the Android that uses WebChromeClient

public class MyWebViewClient extends WebChromeClient

to run a web page on the Android as an application . The original intent was to keep the displays for apps (browser, ios, and android) identical . As usually happens, the application grew more complicated over time (5 years) and a local web database is used to store state for faster startup.

With the latest version of the Android Oreo OS, my app gets a ANR warning. I realize it is time to redesign but have a super tight schedule. If I move the initialization code (web database that uses callbacks (promises), ...) into a html 5 web worker, will that code run on a separate thread in Android application (other than the main ui thread?) Will this solve the ANR? Or do I have to totally redesign?

Does a Web Worker run on the main ui android thread or a separate thread? BTW - how about in the latest IOS, are web workers run on the main thread or separate thread?

Thanks in advance for your input.

The webview does not run on the Android UI thread. The problem had nothing to do with the web view at all. Instead the ANR is a known Android Oreo change. And I was able to fix it by following this post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM