Mobile sharpness

Hi, in order to achieve a sharp image on mobile i am using this script:

const pixelRatio = window.devicePixelRatio;
if ( pixelRatio >= 1) {
scalingValue = 1 ; // HDPI displays
}
else {
scalingValue = 0.5; // no-HDPI displays
};
engine.setHardwareScalingLevel(scalingValue / pixelRatio)

I noticed that the view is slightly squished on portrait mode, what is the ideal method of achieving it without any distorted ratios? Thanks.

I believe it comes from too low value in portrait mode.
You may try to make it fixed if lower than fixed value.