You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Jason Ginchereau (JIRA)" <ji...@apache.org> on 2016/02/29 21:23:18 UTC

[jira] [Resolved] (CB-10492) File System API missing in web workers

     [ https://issues.apache.org/jira/browse/CB-10492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Ginchereau resolved CB-10492.
-----------------------------------
    Resolution: Won't Fix

Web workers don't have access to most of the script context. That includes all the script objects injected by Cordova plugins.

Unfortunately the design of Cordova is restricted by the limitations of web workers. Cordova cannot simply provide plugin APIs to web workers because the mechanism that plugins use to communicate with their native-code counterparts is also not available in a web worker context. I think a hypothetical implementation would require an elaborate mechanism to automatically marshal all plugin API calls and results between the web worker and the main UI thread. But that's not something Cordova aspires to do as far as I know.

See also some recent discussion of this issue here:
http://stackoverflow.com/questions/28642547/phonegap-and-webworkers

> File System API missing in web workers
> --------------------------------------
>
>                 Key: CB-10492
>                 URL: https://issues.apache.org/jira/browse/CB-10492
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>         Environment: all
>            Reporter: Jim Mont
>              Labels: file, filesystem, javascript, triaged, worker
>
> All File system APIs (provided by cordova-plugin-file) appear to be missing in web workers.  Oddly I can make XMLHttpRequests of the filesystem with file urls in workers.
> In the main view running the following suggests there is no access to the filesystem directly:
> {code:javascript}
> var blob = new Blob(["onmessage = function(e) { var res, fn, msg; try{ fn = new Function(e.data); res = fn(); msg = JSON.stringify(res); }catch(err){ msg = JSON.stringify(err); }; postMessage(msg+' <> '+fn); }"]);
> var blobURL = window.URL.createObjectURL(blob);
> var worker = new Worker(blobURL);
> worker.onmessage = function(e) {
>   console.log('worker',e)
> };
> worker.postMessage('return 1+1');
> worker.postMessage('return self.File');
> worker.postMessage('return self.requestFileSystem');
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org