runtime.createWorker() function cannot be used

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • When publishing to the Construct Arcade platform, the runtime.createWorker() function cannot be used. Is anyone else experiencing the same issue? Please help me with a solution.

    Tagged:

  • Some additional information:

    I am using the following in the program:

    await runtime.createWorker("./request_worker.js");
    

    Exporting the Construct Arcade platform. doesn’t work.

    After unzipping the file and testing locally, I found during debugging that "request_worker.js" is missing.

    By copying "request_worker.js" to the root directory, it runs perfectly.

    When debugging the Construct Arcade webpage, I found that the directory is "/72797/0/scripts/project/request_worker.js".

    I changed the link to "https://construct-arcade.com/72797/0/scripts/project/request_worker.js"(The link test can be accessed normally).

    await runtime.createWorker("https://construct-arcade.com/72797/0/scripts/project/request_worker.js");
    

    Export and upload, still doesn’t work.

  • You haven't shared a project file so I'm guessing, but I suspect you may need to generate a URL that is relative to the page URL, otherwise it takes it relative to the script being run, which is in a subfolder when exported. Something like new URL("worker.js", location.href).toString() should do the trick.

    However I'd add you probably don't need to use runtime.createWorker() any more - IIRC all modern browsers now support creating nested workers, and that method mainly existed to work around browsers that didn't support that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made a simple mistake. After uploading the new Construct Arcade package, I noticed during debugging that the webpage was using the cached main.js file, which caused the address changes I made not to take effect. After clearing the cache, everything worked fine. The script used is as follows:

    globalThis.messagePort = await runtime.createWorker("./scripts/project/request_worker.js");
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)