I developed a game using ImpactJS and I'm using CocoonJS to run it on Android and iOS. My game needs to execute some AI code, and it takes too long, so I use a WebView for executing the code in a background thread (using CocoonJS forwardAsync method). In Android is working fine, but in iOS the UI thread is blocked until AI code finishes... It's a CocoonJS issue on iOS?
Asked
Active
Viewed 318 times
1 Answers
1
Could you contact Ludei in order to provide some sample code that mimics this behaviour so they can give it a look?

Iker Jamardo Zugaza
- 176
- 6
-
I contacted Ludei, and they told me that, in iOS, the webview runs on the same thread. But they recommended me to use a webworker inside a webview to run code in a background thread ( webworkers are supported since iOS 5). I tested it, and it works like a charm! :) – Sergio Viudes Feb 27 '14 at 11:46
-
Well, it is strange. I have been using forwardAsync quite often and haven't got this problem. Could you provide some code to see what you are trying to accomplish? – Iker Jamardo Zugaza Jul 08 '14 at 02:54
-
I was trying to execute a long running task (AI for this connect 4 game: http://connect4.baviux.com) in a background thread. In Android was working perfectly, but the same code freezes the UI in iOS. Imanol told me that WebView in Android has its own thread, but in iOS runs on the UI thread, so UI freezes. Imanol told me the solution, that was to execute a webworker inside the WebView, and that worked. Here is the link to the question: http://support.ludei.com/hc/communities/public/questions/200857926-Using-WebView-for-execute-some-code-in-a-background-thread?locale=en-us – Sergio Viudes Jul 08 '14 at 08:15