title: Web Worker in cordova - is it supported
body: <p>I can't seem to get my cordova app to execute even a simple web worker, even though the same web worker works in the Chrome browser on the same device. </p>
  
  <p>(Android device, Google Pixel 3, running Android 9, latest patch level. The app was built in PhoneGap build with <code>cli-8.0.0</code>)</p>
  
  <p>Setup in the main thread:</p>
  
  <pre><code>const worker = new Worker('/fake.worker.js');
  worker.postMessage(1337);
  worker.addEventListener('message', event =&gt; console.log("[myWorker] received event from myWorker:", event));
  </code></pre>
  
  <p>And the <code>/fake.worker.js</code> file is just this, no transpilation:</p>
  
  <pre><code>/* eslint-disable no-restricted-globals */
  console.log("fake.worker booted");
  self.addEventListener("message", startCounter);
  
  function startCounter(event) {
      console.log(event.data, self)
      let initial = event.data;
      console.log("fake.worker counter started:", initial);
  
      setInterval(() =&gt; this.postMessage(initial++), 1000);
  }
  </code></pre>
  
  <p>Bottom line, the console never shows anything from the worker, either from the main thread or from the worker thread's <code>console.log</code> statements. </p>
  
  <p>While attached to the device and remote debugging, I can see that <code>('Worker' in window) === true</code> and that the Network tab of the remote console that the <code>fake.worker.js</code> file is indeed loaded. (Serving the file via <code>ngrok</code> from my development laptop - after connecting to the remote console, I changed the location of the web view with <code>window.location.href = 'https://....ngrok...'</code>.) </p>
  
  <p><em>Note</em>: I also tried including the Web Worker via an inline blob (<code>worker-loader</code> for webpack automated this for me, but the concept is shown at <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Embedded_workers" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Embedded_workers</a>) - and even when "embedded", the worker never booted.</p>