-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support background tasks #358
Comments
The web has the service worker. Not sure if fully applicable to tabris.js but we should take a look. http://www.html5rocks.com/en/tutorials/service-worker/introduction/ |
JXcore is able to run JS on multiple V8 instance (multithreaded). Different threads communicate over message passing Could this also be used for Tabris.js? |
On iOS, the JavaScript VM already runs on a different thread. But the UI thread has to wait, as we execute events synchronously. |
As I understand it, a background task could never access the UI (thread executing the main JS instance) directly. |
I have not tried it yet but here is a cordova plugin that used JXCore, I'm guessing this would work in tabris-js |
Hi, Tabris.js team! Any updates on this feature? On initial run, my app downloads ~ 5Mb JSON cache data, and everything is fine except system dialog - app doesn't respond - continue. Even though background task won't be able to interact with UI - event-based approach would be enough for intensive data transfer |
Unfortunately, no updates yet. However, downloading is already asynchronous, what makes you UI block then? Is it the JSON parsing? |
Yes, it does once but takes about 3 seconds to parse ~12000 records. Ok, I'll change JSON from assoc to numeric array and load in chunks of 1000 with visual progress bar. |
If your storage requirements become more demanding you can also resort to a SQLite database via a plugin like: https://github.com/litehelpers/Cordova-sqlite-storage. This should speed up your load time significantly. |
Closing as implemented. |
Any hint/tutorial/suggestions for a "background helloworld app"? |
@jumpjack #1594 (comment) still applies. If you're looking to create a background task from the UI (i.e. multithreading) see the Worker example |
Thanks, I was just trying to figure out if it is possible to write an app which constantly monitors, in background, a value provided by a server, and I think now it is. |
Like I mentioned above, you're not going to be able to keep the app running in the background to poll for a value Instead, you should have the server push a notification with Firebase Cloud Messaging. You can use tabris-plugin-firebase for this |
I don't understand: I wrote a test app which uses setInterval() to periodically update a counter, and it is working fine in background, even for some minutes, so I assume I can also do something else besides updating the counter, i.e. querying the server. (I don't know anything about firebase, I should start studying it from scratch). |
Polling periodically will create a lot of network traffic. Not every user has an unlimited data plan. By switching to push instead of pull the user's device will only recieve the necessary data if and when it occurs. |
I am trying to study firabase, but it's very complicated, and I don't understand how it basically works: is it a server sending notification to my app? But if my tabris app in background is frozen, how can it receive messages? And if it is able to receive messages, then it should also be able to perform other tasks... or not? I am not an android developer, I'm just a javascript developer; I am trying to figure out if the plugin I need is "firebase" or "notification.local", or if I could just "beep" a sound manually when I need to alert the user, which I already successfully tested on my smartphone; together with changing color of status bar (aslo successfully tested), it would be enough for me.... but I need to be sure the app keeps running in background "for all the time I need", not just "for some minutes" ("some"? how many? What does it depend on?!?) |
Currently, all JavaScript code is executed in the UI thread. This is fine for UI updates, but more complex operations will block the UI. We'll need to provide a way to run JS code in the background.
The text was updated successfully, but these errors were encountered: