davemorrissey/subsampling-scale-image-view

Handle cases when DisplayMetrics report incorrect xdpi and ydpi

theimpulson opened this issue · 3 comments

Expected behavior

Images get scaled properly even if the device reports incorrect xdpi and ydpi by using the device's density as a comparison.

Actual behavior

Due to missing checks, the scaling of images is very small.

Steps to reproduce

  • Grab a Nokia 6.1
  • Install any custom OS like LineageOS: Website, GitHub, Downloads in my case.
  • Notice that the device reports incorrect xdpi and ydpi while rest information is correct.

Affected devices

Nokia 6.1, 420 DPI, Custom OS only

Affected images

Any images or apps that use this library are affected. Apps like Tachiyomi, Sync for Reddit, Boost for Reddit are notable examples.

Information reported by the custom OS on the affected device

DisplayMetrics{density=2.625,width=1080,height=1920,scaledDensity=2.625,xdpi=4.031,ydpi=4.031}

Expected fix

Use the device density as a condition to compare the reported xdpi and ydpi before scaling the image and use the best one possible.

Relevant Issue: #505

I opened an issue for this in Tachiyomi as well which is an affected app: https://github.com/inorichi/tachiyomi/issues/4131

This a bug in the custom OS, has it been reported to them? Any app that uses xdpi or ydpi will be broken by this so it seems better to fix the root cause.

I won't say that this is a custom OS issue but a device firmware issue. Other than mine, none of the other devices I am aware of are affected but again this is also a fact that the only device from Nokia that is supporting custom ROMs right now is mine. I noticed some other devices overriding framework values to report an expected xdpi and ydpi:

Then there are devices that are using emulator density property to fix this issue:

You can notice that in the last commit, the date is from 2011, so I can say that this issue exists for a way long time in devices running custom OS.

For now, I have also decided to use the emulator property to set DPI which overrides the value in the framebuffer and makes the apps using the xdpi and ydpi values works but again it is better to have a fallback in the library in my opinion?

Hence, closing this issue.