Skip to content

HiDPI: Physical size from xrandr may be unreliable (can be 0mm x 0mm) #543

@PeterCxy

Description

@PeterCxy

I ran into this issue when trying to run Alacritty, which uses winit, on my GPD Pocket with ArchLinux running GNOME 3.28.2 on Xorg. When starting the program, winit will report the following error:

[winit X11 error] XError {
    description: "BadValue (integer parameter out of range for operation)",
    error_code: 2,
    request_code: 12,
    minor_code: 0
}

Further investigation showed that XConnection::get_output_info returned inf for the HiDPI factor. Reading the source code I realized that the value is calculated from the resolution and the physical size of the screen, which are all fetched from xrandr. Trying to run xrandr directly to see what's happening, and I ended up with

Screen 0: minimum 320 x 200, current 2496 x 1560, maximum 8192 x 8192
DSI-1 connected primary 2496x1560+0+0 right (normal left inverted right x axis y axis) 0mm x 0mm
   1200x1920     60.38*+
   1920x1200     59.88    59.95  
   1920x1080     60.01    59.97    59.96    59.93  
   1600x1200     60.00  
   1680x1050     59.95    59.88  
   1400x1050     59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     60.02  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   700x450       59.96    59.88  
   640x480       60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   640x400       59.88    59.98  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32

Note that the physical size reported by xrandr is absurd, since it is shown as 0mm x 0mm. However, using xdpyinfo I got the normal physical size reported without problem:

screen #0:
  dimensions:    2496x1560 pixels (207x130 millimeters)
  resolution:    306x305 dots per inch
  depths (7):    24, 1, 4, 8, 15, 16, 32
  root window id:    0x16f
  depth of root window:    24 planes

I believe this should be some issue with xrandr, however I have saw some other cases with similar problems without a fix:

https://bbs.archlinux.org/viewtopic.php?id=232288
http://xpra.org/trac/ticket/728

I also confirmed this problem with @farseerfc who also owns the same computer as mine.

Since all the other programs on my system work just fine (including the ones using GTK3, QT5, Java Swing, which all support HiDPI), I am wondering if it is possible for winit to fallback to some other mechanism to determine hidpi factor or simply set it to 1 if the physical screen size cannot be detected. Although this should be a problem of somewhere else, I think we can at least get winit to run on these strange devices...

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugDang, that shouldn't have happenedC - in progressImplementation is proceeding smoothlyD - easyLikely easier than most tasks hereDS - x11Affects the X11 backend, or generally free Unix platforms

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions