Question

2 Followers
1
Avatar

Using WebView for execute some code in a background thread

I'm using a WebView for executing some AI code in a background thread (using CocoonJS.App.forwardAsync), so UI thread is not blocked.

I'm testing my game using CocoonJS launcher on Android and iOS. In Android, everything is working fine, but in iOS the UI thread is blocked. It is supposed that the code must run on background, it isn't?

Sergio Viudes Carbonell

Please sign in to add your answer.

2 answers

1
Avatar

Hello Sergio,

Android WebView has it's own thread but iOS WebView runs in the UI thread. However you can force a background thread en iOs WebView using WebWorkers. According to caniuse.com WebWorkers are supported on Safari Mobile 5.0+:

http://caniuse.com/#search=worker

Regards,

Imanol

Imanol Fernandez