简体   繁体   English

Web Worker是在ui主android线程上运行还是在单独的线程上运行?

[英]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 我有一个使用WebChromeClient的Android版旧应用程序

public class MyWebViewClient extends WebChromeClient 公共类MyWebViewClient扩展了WebChromeClient

to run a web page on the Android as an application . 作为应用程序在Android上运行网页。 The original intent was to keep the displays for apps (browser, ios, and android) identical . 最初的目的是使应用程序(浏览器,ios和android)的显示保持一致 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. 通常,应用程序随着时间的推移(5年)变得越来越复杂,并且使用本地Web数据库存储状态以加快启动速度。

With the latest version of the Android Oreo OS, my app gets a ANR warning. 使用最新版本的Android Oreo OS,我的应用收到ANR警告。 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? 如果我将初始化代码(使用回调(承诺)的Web数据库,...)移到html 5 Web Worker中,那么该代码是否可以在Android应用程序中的单独线程(主ui线程以外的线程)上运行? ANR? Or do I have to totally redesign? 还是我必须完全重新设计?

Does a Web Worker run on the main ui android thread or a separate thread? Web Worker是在ui主android线程上运行还是在单独的线程上运行? BTW - how about in the latest IOS, are web workers run on the main thread or separate thread? 顺便说一句-在最新的IOS中,Web Worker是在主线程上运行还是在单独的线程上运行?

Thanks in advance for your input. 预先感谢您的输入。

The webview does not run on the Android UI thread. webview不能在Android UI线程上运行。 The problem had nothing to do with the web view at all. 该问题与Web视图完全无关。 Instead the ANR is a known Android Oreo change. 相反,ANR是已知的Android Oreo更改。 And I was able to fix it by following this post 我可以按照这篇文章来修复它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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