Screen sharing not working with jitsi-meet-electron-sdk (uncaught error: an object could not be cloned)

Hello,

We are developing from scratch a desktop application based on jitsi-meet-electron-sdk with plain javascript. The problem is when the script executes the setupScreenSharingRender(api); function I get an error on the console stating uncaught error: an object could not be cloned. So as a result I am not able to share my screen even if the iframe is loaded and the conference starts.

I use contextBridge to send data from preload.js file to the render scripts so I get the setupScreenSharingRender(api) function in the window object.

Here is the architecture of the UI with the iframe directly rendred on the electron’s mainWindow.

here is some screenshots of the encountred errors on the console.

here my renderer script for enabling screen sharing

const domain = 'my.domain.com';
let api;

const options = {
  roomName: 'testtest2023',
  jwt: 'jwtToken',
  height: 700,
  parentNode: document.querySelector('body')
};

api = new JitsiMeetExternalAPI(domain, options);

jitsiNodeAPI.setupRenderer(api, {});

the setupRender function definition:

function setupRenderer(api, options = {}) {
  initPopupsConfigurationRender(api);

  const iframe = api.getIFrame();

  setupScreenSharingRender(api);

  if (options.enableRemoteControl) {
    new RemoteControl(iframe); // eslint-disable-line no-new
  }

  // Allow window to be on top if enabled in settings
  if (options.enableAlwaysOnTopWindow) {
    setupAlwaysOnTopRender(api, null, { showOnPrejoin: true });
  }

  setupPowerMonitorRender(api);
}

Any help would be greatly appreciated :pray:

Hello @emrah and thank you for your response.
I’m sorry but I’m a bit confused :thinking: … I don’t use Element-Desktop and, unless I’m mistaken, the JS code in your Github response doesn’t seem to solve the screen sharing problem on Electron.

Could you enlighten me a little more please?

I see in the docs setupScreenSharingMain and I don’t see it in your example?

Element-Desktop uses jitsi in an iframe as your application and has the same issue. There are many comments about this issue in this thread that I shared. Check mostly @saghul’s answers in this thread.