admin管理员组文章数量:1426228
I am working on a mobile application that needs to poll a web service on a regular interval (using setInterval). I have made a prototype based on HTML5, but when the mobile browser goes in the background, javascript execution is suspended.
I looked into creating native apps for iOS and Android. On iOS this can be done by asking for a limited amount of processing time when the application enters background mode. On Android I guess I would have to make a service that is started and stopped from the application.
However, I see that in Safari on iOS5, web workers support is back, and that this has already been supported in the Android browser for a while. This makes me wonder, can I use web workers to run javascript in the mobile browsers when they are in the background?
I am working on a mobile application that needs to poll a web service on a regular interval (using setInterval). I have made a prototype based on HTML5, but when the mobile browser goes in the background, javascript execution is suspended.
I looked into creating native apps for iOS and Android. On iOS this can be done by asking for a limited amount of processing time when the application enters background mode. On Android I guess I would have to make a service that is started and stopped from the application.
However, I see that in Safari on iOS5, web workers support is back, and that this has already been supported in the Android browser for a while. This makes me wonder, can I use web workers to run javascript in the mobile browsers when they are in the background?
Share Improve this question edited Sep 5, 2011 at 11:43 Jørgen asked Sep 5, 2011 at 11:20 JørgenJørgen 9,1409 gold badges51 silver badges68 bronze badges1 Answer
Reset to default 3The answer is no.
Unfortunately background applications with HTML5 technologies is no go for mobile. Not only mobile browsers aggressively suspend the page when it is background, but they also can kill the whole browser (tab) if they feel so. Whether you have or have not web workers does not affect this.
Running even native applications on background is not trivial on these operating systems.
What I suggest you is that
Extract background worker part out of your JS and write it in native language (Java, iOS)
Use Phonegap etc. similar wrapper for your application UI
本文标签: javascriptWeb workers in mobile browsersStack Overflow
版权声明:本文标题:javascript - Web workers in mobile browsers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745397957a2656902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论