{"record":{"id":"aa8a613df5446fae","repo":"tw93/Pake","slug":"pake-failed-to-toggle-native-fullscreen","errorCode":null,"errorMessage":"[Pake] Failed to toggle native fullscreen:","messagePattern":"\\[Pake\\] Failed to toggle native fullscreen:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/src/inject/event.js","lineNumber":111,"sourceCode":"  const isMac = /mac/i.test(getDesktopPlatform());\n  const isMacScrollShortcut =\n    event.key === \"ArrowUp\" || event.key === \"ArrowDown\";\n  if (isMac && event.metaKey && isMacScrollShortcut) {\n    handleShortcut(event);\n  }\n}\n\nfunction toggleNativeFullscreen(appWindow) {\n  appWindow\n    .isFullscreen()\n    .then((fullscreen) => {\n      if (document.fullscreenElement && document.exitFullscreen) {\n        return document.exitFullscreen();\n      }\n      return appWindow.setFullscreen(!fullscreen);\n    })\n    .catch((error) => {\n      console.warn(\"[Pake] Failed to toggle native fullscreen:\", error);\n    });\n}\n\nfunction handleWindowFullscreenShortcut(event) {\n  if (\n    !event.isTrusted ||\n    event.repeat ||\n    event.key !== \"F11\" ||\n    !isNonMacDesktop()\n  ) {\n    return;\n  }\n\n  const appWindow = window.__TAURI__?.window?.getCurrentWindow?.();\n  if (!appWindow) {\n    return;\n  }\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/tw93/Pake/blob/c8fe8a3f1a115428e3555c06b3de9b7458aa0d54/src-tauri/src/inject/event.js#L93-L129","documentation":"This is a warning logged in the catch handler of toggleNativeFullscreen. When the F11 shortcut fires, the code queries the current fullscreen state via `appWindow.isFullscreen()` (a Tauri IPC call) and then toggles it with `setFullscreen` or `document.exitFullscreen()`. If the IPC promise rejects — the webview/window handle is unavailable, the window was closed mid-flight, or the platform rejects the fullscreen change — the rejection is caught and logged with this message instead of crashing.","triggerScenarios":"Pressing F11 on Linux/Windows while `window.__TAURI__.window.getCurrentWindow()` returns a stale or already-closed window handle; the `isFullscreen()` or `setFullscreen()` IPC invoke rejects (window destroyed, permissions/capability missing for the window plugin, webview navigating away mid-call); a DOM exitFullscreen() promise rejection is not caught here (only the IPC chain is), but an IPC failure of isFullscreen/setFullscreen always produces this warning.","commonSituations":"Rapidly double-pressing F11 so the first call is still pending when the window state changes; closing the window while a fullscreen toggle IPC is in flight; a packaged app whose Tauri capabilities do not grant `window:allow-is-fullscreen` / `window:allow-set-fullscreen`; running on a Wayland compositor where fullscreen requests are rejected by the window manager.","solutions":["Grant the required permissions in src-tauri/capabilities: add `window:allow-is-fullscreen` and `window:allow-set-fullscreen` to the capability allowlist.","Check whether the warning is transient (window closing during the call) — it is a console.warn and safe to ignore if fullscreen still works on the next F11 press.","On Linux/Wayland, verify the compositor permits fullscreen; test with `--decorations=false` or under X11 to isolate Wayland-specific rejection.","Guard the call by re-fetching the current window and confirming it is still valid (`window.__TAURI__.window.getCurrentWindow()`) before toggling, and debounce repeated F11 presses (event.repeat is already filtered; add a timestamp-based throttle if needed)."],"exampleFix":"// before\nconst appWindow = window.__TAURI__?.window?.getCurrentWindow?.();\nif (!appWindow) return;\ntoggleNativeFullscreen(appWindow);\n// after\nconst appWindow = window.__TAURI__?.window?.getCurrentWindow?.();\nif (!appWindow) return;\ntry {\n  await appWindow.isVisible(); // probe IPC liveness before toggling\n  toggleNativeFullscreen(appWindow);\n} catch {\n  return; // window closed or IPC unavailable\n}","handlingStrategy":"try-catch","validationCode":"const appWindow = window.__TAURI__?.window?.getCurrentWindow?.();\nif (!appWindow || typeof appWindow.isFullscreen !== \"function\") return; // IPC bridge missing","typeGuard":"function isValidAppWindow(win) {\n  return Boolean(win) && typeof win.isFullscreen === \"function\" && typeof win.setFullscreen === \"function\";\n}","tryCatchPattern":"appWindow\n  .isFullscreen()\n  .then((fullscreen) => appWindow.setFullscreen(!fullscreen))\n  .catch((error) => {\n    if (String(error).includes(\"window not found\")) return; // window closed, ignore\n    console.warn(\"[Pake] Failed to toggle native fullscreen:\", error);\n  });","preventionTips":["Grant window:allow-is-fullscreen and window:allow-set-fullscreen in the Tauri capabilities file.","Debounce fullscreen shortcut handling to avoid overlapping in-flight IPC toggles.","Re-acquire the current window handle instead of caching it across navigations.","Test F11 on the actual target platforms (Wayland especially rejects some fullscreen requests)."],"tags":["javascript","tauri-ipc","fullscreen","window-management"],"backgroundTag":"unsupported-operation","analyzedSha":"c8fe8a3f1a115428e3555c06b3de9b7458aa0d54","analyzedAt":"2026-09-20T12:02:36.283Z","contentChangedAt":"2026-09-20T12:02:36.283Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}