{"record":{"id":"33f5a67309bc1321","repo":"m1k1o/neko","slug":"unsupported-screen-rate-d","errorCode":null,"errorMessage":"unsupported screen rate %d","messagePattern":"unsupported screen rate (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/pkg/xorg/xorg.go","lineNumber":234,"sourceCode":"\tstatus := C.XSetScreenConfiguration(c_width, c_height, c_rate)\n\tif status != C.RRSetConfigSuccess {\n\t\t// create new screen configuration\n\t\tC.XCreateScreenMode(c_width, c_height, c_rate)\n\n\t\t// screen configuration should exist now, set it\n\t\tstatus = C.XSetScreenConfiguration(c_width, c_height, c_rate)\n\t}\n\n\tvar err error\n\n\t// if screen configuration was not set successfully, return error\n\tif status != C.RRSetConfigSuccess {\n\t\terr = fmt.Errorf(\"unknown screen configuration %s\", s.String())\n\t}\n\n\t// if specified rate is not supported a BadValue error is returned\n\tif status == C.BadValue {\n\t\terr = fmt.Errorf(\"unsupported screen rate %d\", s.Rate)\n\t}\n\n\treturn s, err\n}\n\nfunc GetScreenSize() types.ScreenSize {\n\tmu.Lock()\n\tdefer mu.Unlock()\n\n\tc_width, c_height, c_rate := C.int(0), C.int(0), C.short(0)\n\tC.XGetScreenConfiguration(&c_width, &c_height, &c_rate)\n\n\treturn types.ScreenSize{\n\t\tWidth:  int(c_width),\n\t\tHeight: int(c_height),\n\t\tRate:   int16(c_rate),\n\t}\n}","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/xorg/xorg.go#L216-L252","documentation":"ChangeScreenSize detects C.BadValue from the X server, which XRandR returns when the requested refresh rate is not supported for the selected mode, and reports 'unsupported screen rate %d'. The configuration call failed specifically because of the Rate field. Note the code also assigns the generic 'unknown screen configuration' error first, so the BadValue branch overwrites it when it applies.","triggerScenarios":"Calling ChangeScreenSize/SetScreenSize with a ScreenSize whose Rate is not offered by the X server for the given resolution (e.g. Rate 144 on a 60 Hz panel).","commonSituations":"Clients letting users pick arbitrary refresh rates; presets copied from another machine; HiDPI/TV modes supporting only 24/30/60 Hz; fractional rates (59.94) requested as integers.","solutions":["Request a refresh rate listed in the XRandR mode list for the chosen resolution (xrandr -q)","Omit/normalize the rate: pick the mode's default rate instead of a hardcoded value","Cache and refresh supported rates via GetScreenSize/RRGetScreenInfo before applying","Add a cvt/xrandr modeline for exotic rates if the hardware truly supports them"],"exampleFix":"// before\nxorg.SetScreenSize(types.ScreenSize{Width: 1920, Height: 1080, Rate: 144})\n// after\nmode := pickMode(supportedModes, 1920, 1080) // rate from xrandr query\nxorg.SetScreenSize(types.ScreenSize{Width: 1920, Height: 1080, Rate: mode.Rate})","handlingStrategy":"validation","validationCode":"// validate the rate against modes reported by the X server\nmodes := queryXRandRModes(width, height)\nfunc rateSupported(rate uint32, modes []Mode) bool {\n    for _, m := range modes {\n        if m.Rate == rate { return true }\n    }\n    return false\n}","typeGuard":"func isUnsupportedRate(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"unsupported screen rate\")\n}","tryCatchPattern":"s, err := xorg.SetScreenSize(want)\nif isUnsupportedRate(err) {\n    // retry with the mode's default rate\n    want.Rate = defaultRateFor(want.Width, want.Height)\n    s, err = xorg.SetScreenSize(want)\n}","preventionTips":["Read the allowed rates for the chosen resolution from XRandR before setting","Never hardcode refresh rates; derive them from the queried modelist","Handle fractional rates (59.94 vs 60) when matching modes","On BadValue, retry with the default rate for the resolution"],"tags":["x11","xrandr","display","refresh-rate"],"backgroundTag":"unsupported-screen-mode","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}