Puppeteer MediaRecorder NotReadableError on Ubuntu during Display Capture

Running Puppeteer on Ubuntu to capture desktop video fails with getDisplayMedia throwing NotReadableError, whereas it works on Windows. New snippet below:

let displayStream = await navigator.mediaDevices.getDisplayMedia({
  video: { displaySurface: 'window', width: 1280, height: 720 }
});

let recorderInstance = new MediaRecorder(displayStream);
recorderInstance.ondataavailable = (dataEvent) => {
  // process video segments
};

Based on my experience with Puppeteer on Ubuntu, the NotReadableError often stems from permission issues and the underlying display server settings. I encountered a similar problem when running video capture tasks on Ubuntu, and I found that using an Xorg session instead of Wayland helped resolve the display capture restrictions. Adjusting session settings and ensuring necessary system permissions for screen sharing can be effective. Verifying that the launch flags and environment configurations are correctly set up is an approach that worked well in my case.

hey, i had similar probs on ubuntu. i switched from wayland to xorg and it worked fine, also double-check your screen permissions. sometimes a couple of chrome debug flags can make a difference too. good luck!

I experienced a similar NotReadableError when I was using Puppeteer on Ubuntu. For me, aside from switching between Wayland and Xorg, I noticed that enabling certain Chrome flags related to GPU acceleration reduced errors. I also made sure that my user was added to the video group to have full device access. Sometimes the error persists because of how Ubuntu handles media capture under restrictive permissions; resetting udev rules and ensuring that all related dependencies were up to date helped to mitigate this issue on my end.

I encountered a similar challenge and eventually traced the problem to a combination of sandboxing and specific Chromium versions on Ubuntu. After experimenting, I adjusted the environment by updating Chromium and modifying the sandbox parameters, which allowed the MediaRecorder to initialize properly. In one particular instance, modifying security settings in a controlled test environment resolved the NotReadableError. My experience indicates that a careful review of both the browser’s configuration and system-level security policies is necessary to diagnose and fix this issue.