nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

Fails in Electron renderer process #125

Open iosimliviu opened 2 years ago

iosimliviu commented 2 years ago

In which case I run into the following error:

Uncaught (in promise) Error: The V8 platform used by this instance of Node does not support creating Workers
    at new Worker (internal/worker.js:148)
    at new WorkerThread (/Users/liviuiosim/Do…workerThreads.js:14)
    at Object.forkWorkerThread (/Users/liviuiosim/Do…workerThreads.js:52)
    at ThreadedClassManagerClassInternal._createFork (/Users/liviuiosim/Do…cess/manager.js:569)
    at ThreadedClassManagerClassInternal.findNextAvailableChild (/Users/liviuiosim/Do…cess/manager.js:126)
    at /Users/liviuiosim/Do…hreadedClass.js:144
    at new Promise (<anonymous>)
    at Object.threadedClass (/Users/liviuiosim/Do…threadedClass.js:29)
    at AtemSocket.<anonymous> (/Users/liviuiosim/Do…ib/atemSocket.js:90)
    at Generator.next (<anonymous>)

I understand that this might be more of an Electron issue, as specified here, and here

I have the following BrowserWindow options:

win = new BrowserWindow({
    webPreferences: {
      nodeIntegrationInWorker: true,
      nodeIntegration: true,
      allowRunningInsecureContent: (serve) ? true : false,
    },
  });

With the following versions:

"electron": "^11.3.0",
"atem-connection": "^2.4.0",

Is there any other implementation with an electron-friendly thread library? Or does anybody have an idea of a potential fix?

Julusian commented 2 years ago

I know the library works when used in the main electron process, but it appears that the renderer process is doing something odd that is tripping up the threading library.

The only suggestion I have for now is to not use it in the renderer process. Or you could try enabling the option disableMultithreaded, but that is likely to cause the connection to die when other cpu intensive stuff is happening in your app.

I am not sure when I will have a chance to look at fixing the underlying issue. The threading library we use does support web-workers, but I have never tried that so it might not be easy

iosimliviu commented 2 years ago

Thank you for your response. It indeed works well in the main electron process.

I am having some issues when the application is packed versus not packed. Basicly when running it in the development environement it works, and when I make a build it doesn't, the connection is not taking place.

Have you guys encountered anything similar?

I am using "electron-builder": "^22.11.7" with "electron": "^11.5.0" for builds.

Laiba-Akram commented 2 years ago
  • I'm submitting a ... [ x ] bug report [ ] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project
  • Summary Everything works fine until I try to make a call to atem.connect()

In which case I run into the following error:

Uncaught (in promise) Error: The V8 platform used by this instance of Node does not support creating Workers
    at new Worker (internal/worker.js:148)
    at new WorkerThread (/Users/liviuiosim/Do…workerThreads.js:14)
    at Object.forkWorkerThread (/Users/liviuiosim/Do…workerThreads.js:52)
    at ThreadedClassManagerClassInternal._createFork (/Users/liviuiosim/Do…cess/manager.js:569)
    at ThreadedClassManagerClassInternal.findNextAvailableChild (/Users/liviuiosim/Do…cess/manager.js:126)
    at /Users/liviuiosim/Do…hreadedClass.js:144
    at new Promise (<anonymous>)
    at Object.threadedClass (/Users/liviuiosim/Do…threadedClass.js:29)
    at AtemSocket.<anonymous> (/Users/liviuiosim/Do…ib/atemSocket.js:90)
    at Generator.next (<anonymous>)
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

I understand that this might be more of an Electron issue, as specified here, and here

I have the following BrowserWindow options:

win = new BrowserWindow({
    webPreferences: {
      nodeIntegrationInWorker: true,
      nodeIntegration: true,
      allowRunningInsecureContent: (serve) ? true : false,
    },
  });

With the following versions:

"electron": "^11.3.0",
"atem-connection": "^2.4.0",

Is there any other implementation with an electron-friendly thread library? Or does anybody have an idea of a potential fix?

Updated the electron version