FredrikSandell / angular-workers

MIT License
69 stars 25 forks source link

not supporting ie 10 #6

Open MaestroJurko opened 9 years ago

MaestroJurko commented 9 years ago

http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string

Blob problem

antony-k1208 commented 8 years ago

Hey,

will this be fixed in near future?

Regards, Antony

FredrikSandell commented 8 years ago

Hi,

The root cause of this issue is that IE does not support the blob-url feature used to initialize the web worker body. I think this the a relevant open issue: https://connect.microsoft.com/IE/feedback/details/801810/web-workers-from-blob-urls-in-ie-10-and-11

To solve this the code would have to get by without sending the code directly to the web worker. My solution proposal would be to initialize the web worker by loading a simple script from the server (this would only be needed in the case of IE). This script would wait for an initial post from the main thread. The initial post to the web worker would contain the worker body in the form of a string. This string, along with some additional boot scripts would need to be eval-ed in the worker thread. After all that is successful the worker promise would resolve and the caller can start to use the worker.

In theory I think it should work. But it would require additional configuration and a lot of changes to the library. Another simpler approach would be to simply run web workers in the main thread in the IE case (essentially nullifying any performance gains in IE).

Anyway, right now I do not have time to look in to this. Sorry I cannot give you a timeline. Pull requests are very welcome:)

antony-k1208 commented 8 years ago

Hey,

cool, thank you very much for your fast and detailed feedback on this issue. The simpler solution sounds absolutely sufficient for our needs. Some tips how to achieve this?

Thanks again in advance!

FredrikSandell commented 8 years ago

Hi!

Ok, so implementing the bare minimum (executing the worker in the main thread) would require you to: 1: have a reliable way of determining the browser. 2: Write a new worker template which is only used in the IE case. This template will probably be a lot simpler. Not import dependencies explicitly (trust that the user have loaded them already). Also the template does not need to manipulate the global scope to simulate a DOM:). 3: createAngularWorker will need a special case for IE that evals the populated worker template instead of serializing it to a blob. The 'initDone' message can be disregarded in the IE case since after the eval we know the worker is initialized (it is run synchronously) 4: In this section:

var buildAngularWorker = function (initializedWorker) {
        var that = {};
        that.worker = initializedWorker;
        that.run = function (input) {

the run method would need a special case for IE. Instead of communicating with the worker a direct invocation to the worker service can be made since it defined in the same thread context (the eval should have set it up already)

I may have missed a couple of things, but hopefully this helps a bit.

/Fredrik

antony-k1208 commented 8 years ago

Hey,

thanks again for your time and detailed answer. Seems to be much more complicated than i thought..at least for me. Any ideas when you will have enough time to face this issue? :/

Cheers, Antony

FredrikSandell commented 8 years ago

Sorry, I am not able to provide you with a timeline for when this will be fixed. Will notify you when I have pushed something that may solve your issue.

BR, Fredrik

ppollono commented 8 years ago

@FredrikSandell any news on the IE support?

antony-k1208 commented 8 years ago

Hey, not from our side..we are now using operativejs and some other micro frameworks we need to achieve our goals. Maybe this helps out!

FredrikSandell commented 8 years ago

Sorry no news. Have not had time to work on this project. Pull requests are always welcome!