Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Created June 9, 2026 05:05
Show Gist options
  • Select an option

  • Save Noitidart/1f1ab3a4c8002da2550818d4155eb7b9 to your computer and use it in GitHub Desktop.

Select an option

Save Noitidart/1f1ab3a4c8002da2550818d4155eb7b9 to your computer and use it in GitHub Desktop.
Electron Fiddle: app.dock.bounce('critical') throttling repro — macOS Tahoe
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Dock Bounce Test</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
padding: 40px;
background: #1e1e1e;
color: #e0e0e0;
}
h1 { margin-top: 0; }
.step { margin: 12px 0; line-height: 1.5; }
code { background: #333; padding: 2px 6px; border-radius: 4px; }
.status { margin-top: 24px; padding: 12px; background: #2a2a2a; border-radius: 6px; font-family: monospace; }
</style>
</head>
<body>
<h1>Dock Bounce Test</h1>
<div class="step">1. Click <strong>Start Bounce</strong> below.</div>
<div class="step">2. Switch to another app (Cmd+Tab or click away). The dock icon should bounce <strong>continuously</strong>.</div>
<div class="step">3. Wait ~60 seconds. Observe whether bouncing continues at the same rate or slows down to ~2 bounces/min.</div>
<div class="step">4. Click the dock icon to stop the bounce.</div>
<button id="start" style="margin-top:20px;padding:10px 20px;font-size:16px;cursor:pointer;">Start Bounce</button>
<button id="stop" style="margin-top:20px;padding:10px 20px;font-size:16px;cursor:pointer;" disabled>Cancel Bounce</button>
<div class="status" id="log">Ready.</div>
<script>
const { app } = require('electron');
const logEl = document.getElementById('log');
const startBtn = document.getElementById('start');
const stopBtn = document.getElementById('stop');
let bounceId;
let startTime;
function log(msg) {
const ts = new Date().toLocaleTimeString();
logEl.textContent = `[${ts}] ${msg}`;
}
startBtn.addEventListener('click', () => {
bounceId = app.dock.bounce('critical');
startTime = Date.now();
log(`bounce('critical') called — id: ${bounceId}. Switch away from this window now.`);
startBtn.disabled = true;
stopBtn.disabled = false;
});
stopBtn.addEventListener('click', () => {
if (bounceId !== undefined) {
app.dock.cancelBounce(bounceId);
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
log(`cancelBounce(${bounceId}) called after ${elapsed}s.`);
bounceId = undefined;
startBtn.disabled = false;
stopBtn.disabled = true;
}
});
</script>
</body>
</html>
const { app, BrowserWindow } = require('electron');
let mainWindow;
let bounceId;
function createWindow() {
mainWindow = new BrowserWindow({
width: 600,
height: 400,
title: 'Dock Bounce Test',
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
mainWindow.loadFile('index.html');
mainWindow.on('close', () => {
if (bounceId !== undefined) {
app.dock.cancelBounce(bounceId);
}
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (bounceId !== undefined) {
app.dock.cancelBounce(bounceId);
}
app.quit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment