web workers in safari and firefox

0 favourites
  • 2 posts
From the Asset Store
Easily add web monetization to your game and start earning money from supporting visitors.
  • Hello everyone. I have such a question. There is a small plugin that does only what saves user points and sends them to the server. I am not the author of it, I am very superficially familiar with constuct3.The plugin works fine in chrome. I also need to make it work on both ios with safari and firefox. Unfortunately, there is a big problem in these browsers that prevents the plugin from working - it is sending messages via self.postmessage to web workers.

    This works fine in chrome, but problems start with safari and firefox.

    As far as I could understand, during initialization, the constuct3 engine checks which software environment we use,

    and if OffscreenCanvas (I'm not sure exactly if it is the main culprit) is not supported by the browser, then web workers simply does not initialize (1 screenshot). Then, after going through the debugger, I saw that in non-working browsers "self" stores "window", and in chrome "self" - "DedicatedWorkerGlobalScope" (2,3 screenshot), and therefore chrome sends everything perfectly, and firefox and safari require another argument(I tried adding "*" with the second argument, it doesn't help). I actually have a question, is it possible to somehow make the program work on firefox and ios without rewriting it completely, if the mechanics of the add-on is tied to web workers? I tried to write _useWorker = true directly in the code, but initialization still does not happen.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • forgot to add the sample code:

    	self.C3.Plugins.saveAPI.Acts =
    		initLib(myParams) {
    			console.log("********** Plugin initLib: " + myParams);
    			C3.Plugins.saveAPI._x_this = this;
    			self.postMessage(C3.Plugins.saveAPI.prefixFromPlugin + "PluginInitLib," + myParams);
    			if (typeof self.onmessageFromPlugin == 'function') {
    				self.onmessageFromPlugin({data:C3.Plugins.saveAPI.prefixFromPlugin + "PluginInitLib," + myParams});
    		saveLib(data) {
    			console.log("********** Plugin saveLib: " + data);
    			self.postMessage(C3.Plugins.saveAPI.prefixFromPlugin + "saveAPIdataToSave," + data);
    			if (typeof self.onmessageFromPlugin == 'function') {
    				self.onmessageFromPlugin({data:C3.Plugins.saveAPI.prefixFromPlugin + "saveAPIdataToSave," + data});
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)