Cordova plugins are not functional in Worker
If some plugins are installed for example(https://github.com/apache/cordova-plugin-file.git) the tabris js worker won't launch and returns an error(the image below).
Also no cordova plugin works inside a worker.

Expected behavior
Worker can work with all the cordova plugins and the coordova plugin can works inside a worker
- Tabris.js version: 3.2.1
- Device: Huawei P10 lite, Samsung Galaxy S6 ect...
- OS: Android 8.1
Do you see a native log entry in the android adb log?
nope i check it right now
@mpost , The log here
Thanks. The log does not show any more info. In general, if a plugin requires to run in a cordova environment, it will not run in a worker. A worker has no ui whereas a cordova environment represents a ui. We will look into it.
ok thank you and don't forget to look into the fact that if some plugin are installed the worker does not working. In my case i just add cordova plugin file in config.xml after the build if i load a worker i've the error noted above
Cordova plugin file is an essential part of my app design and i need to use worker too for some huge background tasks, unfortunatly i can't have both right now
what features are you missing from the tabris fs api?
create a folder, example i want to create a folder to this specific destination file:///storage/emulated/0/ i tried with fs api but no success, Move file to one folder to another Delete an entire folder Check if a folder exist
My hope please is that you will make a little update 3.3.1 to fixed the problem with the worker
Do you require more fs support that goes beyond what we will implement in https://github.com/eclipsesource/tabris-js/issues/1543?
@mpost yes, move or copy one file to one dir to another possibility to create a dir with this path file:///storage/emulated/0/
Copy can be emulated with the above read and write and delete commands. Writing to the dir you mentioned above should be possible when allowed by the system.
with cordova plugin file it's possible with no problem i do it in my app
do you think that you can make something for the worker problem soon?or i need to wait for the next 3.4 release?
We can investigate the issue but there are no current plans for a 3.3.1. In 3.4 we will implement #1543 which should also remove the requirement to use the fs plugin.
ok thank you
@mpost I think you should seriously investigate this problem, because several cordova plugins prevent workers from working, I discovered two more.
https://www.npmjs.com/package/cordova-plugin-extended-device-information
https://github.com/apache/cordova-plugin-network-information
@ishigo1987 I have investigated this issue and found a strange solution. If you pay attention to JS sources of the mentioned plugins, you can realize the usage of the Cordova feature channel.waitForInitialization here This feature collides with the Tabris Worker mechanism.
How to overcome this?
If you move the channel.initializationComplete(Line: 59) after the exec(Line: 61) function here, then the issue will be solved.
You can fork these plugins, do these little updates and use them in your project.
P.S.
Other plugins could use channel.[name].fire();, and I think you could also move this after the exec function. Additionally, channel.initializationComplete([name]); can be used instead of channel.[name].fire();.
Thank you i will check and i will let you know
It worked, thank you very much. @elshadsm
@mpost any new about the fact that the cordova plugins does not working inside the Tabris Worker?
@elshadsm hello, any tips to help me with the fact that no cordova plugins work inside a Tabris Worker? Thank You
There are no updates yet. What features do you want to use in the worker?
I'll explain. It might take a little while. Sorry about that, I implemente a contact import feature.
- I can't retrieve the user's contacts in a worker, because I use a cordova plugin for that.
- Once I have retrieved the contacts I have to put them in a localStorage and retrieve them in a worker, so doing a JSON.stringify() on an array of 6000 contacts sometimes blocks the ui for 1 second or more because LocalStorage is not asynchronous,
- After working in the worker I'm forced to go back to the main thread to insert the collected contacts in an sqlite database, because it wouldn't work in a worker. If we could use the cordova plugins in the workers I would do all this work without going back to the main thread and blocking it from time to time.
Thanks for the info. It will help us to asses the issue further.
As a side note on your issue: You could use the fs api to store the data. It is able to write to disc async, which would not block. It is also more efficient than the localStorage which is more suited for small amounts of key/value data.
Ok got it
Since cordova plugins do not work out of the box, i will reopen this issue.