{"record":{"id":"76618e10e566be9b","repo":"kovidgoyal/kitty","slug":"invalid-cached-window-size-ignoring","errorCode":null,"errorMessage":"Invalid cached window size, ignoring","messagePattern":"Invalid cached window size, ignoring","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/os_window_size.py","lineNumber":64,"sourceCode":"    padding: float = getattr(opts.single_window_padding_width, which)\n    if padding < 0:\n        padding = getattr(opts.window_padding_width, which)\n    return float(padding + margin)\n\n\ndef initial_window_size_func(opts: WindowSizeData, cached_values: dict[str, Any]) -> Callable[[int, int, float, float, float, float], tuple[int, int]]:\n\n    if 'window-size' in cached_values and opts.remember_window_size:\n        ws = cached_values['window-size']\n        try:\n            w, h = map(sanitize_window_size, ws)\n\n            def initial_window_size(*a: Any) -> tuple[int, int]:\n                return w, h\n\n            return initial_window_size\n        except Exception:\n            log_error('Invalid cached window size, ignoring')\n\n    w, w_unit = opts.initial_window_sizes.width\n    h, h_unit = opts.initial_window_sizes.height\n\n    def get_window_size(cell_width: int, cell_height: int, dpi_x: float, dpi_y: float, xscale: float, yscale: float) -> tuple[int, int]:\n        if not is_macos and not is_wayland():\n            # Not sure what the deal with scaling on X11 is\n            xscale = yscale = 1\n\n        def effective_margin(which: EdgeLiteral) -> float:\n            ans: float = getattr(opts.single_window_margin_width, which)\n            if ans < 0:\n                ans = getattr(opts.window_margin_width, which)\n            return ans\n\n        def effective_padding(which: EdgeLiteral) -> float:\n            ans: float = getattr(opts.single_window_padding_width, which)\n            if ans < 0:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/os_window_size.py#L46-L82","documentation":"kitty caches the last OS window size to restore geometry on restart; if the cached value is corrupt or unparseable (e.g. truncated cache file or changed format), initial_window_size_func logs this and falls back to computing the size from config.","triggerScenarios":"The window size cache file exists but raises any Exception while being parsed inside initial_window_size_func; called from add_os_window/add_os_panel/_run_app at startup or when opening a new window.","commonSituations":"Corrupted cache after a crash, kitty upgrade changing the cache format, or a read-only/truncated cache directory.","solutions":["Ignore it: kitty automatically falls back to config-based sizing","Delete kitty's cache dir (e.g. ~/.cache/kitty) so the size cache is regenerated","If persistent, check initial_window_width/height and remember_window_size settings"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat as benign; kitty falls back to config sizing","Clear ~/.cache/kitty after crashes or version upgrades"],"tags":["kitty","window-size","cache","startup"],"backgroundTag":"corrupt-cache-file","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}