MagicMirrorOrg/MagicMirror · warning

Could not get display size, using defaults ...

Error message

Could not get display size, using defaults ...

What it means

In the Electron main process, createWindow queries the primary display's work area size to size the mirror window. If electron.screen.getPrimaryDisplay() throws — e.g. no display is attached or Electron cannot access screen information (common on headless systems or when the app is not ready) — the code falls back to a default 800x600 window and logs this warning.

Source

Thrown at js/electron.js:44

 * Keep a global reference of the window object, if you don't, the window will
 * be closed automatically when the JavaScript object is garbage collected.
 */
let mainWindow;

/**
 *
 */
function createWindow () {

	/*
	 * see https://www.electronjs.org/docs/latest/api/screen
	 * Create a window that fills the screen's available work area.
	 */
	let electronSize = { width: 800, height: 600 };
	try {
		electronSize = electron.screen.getPrimaryDisplay().workAreaSize;
	} catch {
		Log.warn("Could not get display size, using defaults ...");
	}

	applyElectronSwitches(app.commandLine, config.electronSwitches);
	let electronOptionsDefaults = {
		width: electronSize.width,
		height: electronSize.height,
		icon: "favicon.svg",
		x: 0,
		y: 0,
		darkTheme: true,
		webPreferences: {
			contextIsolation: true,
			nodeIntegration: false,
			zoomFactor: config.zoom
		},
		backgroundColor: "#000000"
	};

View on GitHub (pinned to 4b4a59534f)

Solutions

  1. Attach/enable a display or start the X server so the system has a primary display.
  2. If no display is intended, run in server-only mode: node serveronly (or MM_SERVERONLY=true) instead of the Electron app.
  3. For headless setups, use a virtual display (e.g. xserver-xorg with a dummy driver, or run inside a real desktop session).
  4. Ensure Electron starts after app 'ready' (this is handled by the app; just don't remove the ready listener).
  5. Ignore the warning if the 800x600 default is acceptable — the window can be resized via electronOptions in config.js.

Example fix

// before (headless)
npm start   # Electron fails to find display, 800x600 window
// after
node serveronly   # or attach a display / configure a dummy X screen
Defensive patterns

Strategy: fallback

Validate before calling

// Before launching Electron, detect a usable display
const hasDisplay = !!process.env.DISPLAY || !!process.env.WAYLAND_DISPLAY;
if (!hasDisplay) console.warn("No display detected; run 'node serveronly' instead of the Electron app.");

Type guard

function displayAvailable(electron) {
  try { return Boolean(electron.screen.getPrimaryDisplay()); }
  catch { return false; }
}

Try / catch

try {
  const size = electron.screen.getPrimaryDisplay().workAreaSize;
} catch {
  Log.warn("No display; using default 800x600 window size");
}

Prevention

When it happens

Trigger: MagicMirror run with Electron on a machine with no attached/active display (headless server, X not running), or getPrimaryDisplay() called before the app 'ready' event so screen info is unavailable.

Common situations: Running the full MagicMirror (not serveronly) on a Raspberry Pi with no monitor or via SSH; Docker containers without a display; broken X/Wayland sessions where the screen module reports no primary display.


AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31). Data as JSON: /api/errors/ab86c0064ef42e7e. Report an issue: GitHub.