Hi all
I worked out why Chrome doesn't like my worker js files. This is very
similar to the problem with Gears getting confused with Unicode
manifest files.
// index.js
window.onerror = function(e) {
alert(e);
}
var wp = google.gears.factory.create('beta.workerpool');
wp.onmessage = function(a, b, msg) {
alert(msg.body);
}
var c = wp.createWorkerFromUrl('worker.js');
wp.sendMessage('test', c);
// worker.js
var wp = google.gears.workerPool;
wp.onmessage = function(a, b, msg) {
wp.sendMessage('reply: ' + msg.body, msg.sender);
}
The alert box came up with this: "Error in worker 1 at line 1.
Uncaught SyntaxError: Unexpected token ILLEGAL"
I had to go and re-save worker.js as ANSI in Notepad and what do you
know, it works.
Note: I'm using Chrome dev release - 0.4.154.23.
Chris
On Nov 19, 8:27 am, Khookie <[EMAIL PROTECTED]> wrote:
> yeah I thought it was pretty odd for a bug like that to manifest on a
> production version.
>
> bummer... oh well, createWorker is working very well for me at the
> moment so I'm not as concerned as I was... I might go try Google Docs
> later on in Chrome to see if the same issue occurs then.
>
> Cheers
>
> Chris
>
> On Nov 19, 3:36 am, Aaron Boodman <[EMAIL PROTECTED]> wrote:
>
> > Hi Chris,
>
> > I tried your code in Google Chrome and it worked for me. Also, we have
> > pretty extensive unit testing for createWorkerFromUrl() and Google
> > Docs relies on it, so I think something else must be up.
>
> > One thing off the top of my head ... createWorkerFromUrl() doesn't
> > support file:// URLs. It shouldn't result in this error, but that is
> > something I always forget.
>
> > - a
>
> > On Tue, Nov 18, 2008 at 12:52 AM, Khookie <[EMAIL PROTECTED]> wrote:
>
> > > Hi
>
> > > Managed to narrow it down:
>
> > > It seems that createWorkerFromUrl does not work in Google Chrome - at
> > > least my Google Chrome anyhow. Sample code below:
>
> > > var _wp = google.gears.factory.create('beta.workerpool');
> > > _wp.onmessage = function(a, b, msg) {
> > > alert('Received message: ' + msg.body);
> > > }
> > > var _child = _wp.createWorkerFromUrl('worker.js');
> > > // var _child = _wp.createWorker("var _wp = google.gears.workerPool;
> > > _wp.onmessage = function(a, b, msg) { _wp.sendMessage('Got message: '
> > > + msg.body, msg.sender); }");
> > > _wp.sendMessage('test', _child);
>
> > > createWorker works fine.
>
> > > Cheers
>
> > > Chris
>
> > > On Nov 18, 9:18 am, Khookie <[EMAIL PROTECTED]> wrote:
> > >> Hi
>
> > >> Just wondering anyone has had big difficulties with debugging Gears
> > >> applications in Chrome? Especially ones with workerpools.
>
> > >> I keep getting the below error in the Javascript Console on the line
> > >> which creates the worker (i.e. wp.createWorkerFromUrl).
>
> > >> Uncaught TypeError: Property 'onerror' of object [object global] is
> > >> not a function
>
> > >> and the funny thing was... I commented all the code in the worker file
> > >> out and it still came up with that error message. The code works fine
> > >> in both IE & Firefox.
>
> > >> Chris