mykola-mokhnach / Appium-iOS-Inspector

Apache License 2.0
145 stars 60 forks source link

Scaling issue in inspector when running on iPhone 6plus (or Retina HD in general?) #3

Closed lambourn closed 7 years ago

lambourn commented 7 years ago

When running on an iPhone 6plus the inspector seems to get confused on point sizes and dimensions. Not sure if this is a general Appium issue or something inside the inspector.

E.g. inside the app I have a UILabel whose frame takes the whole width of the screen (portrait mode) and has it's height set to 22. On an iPhone 6plus this rect is rect(0, 0, 414, 22) in point size

In the AppiumAUT xml this is delivered (correctly) as: <UIAStaticText name="What’s new?" label="What’s new?" value="What’s new?" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/3" x="0" y="0" width="414" height="22"> </UIAStaticText>

Inside the inspector, the rect gets displayed as: Rect: x=0, y=0, h=44, w=828 which looks as if the inspector assume 2x Retina display whereas on the 6plus it is 3x

Due to this, the screenshot is larger than expected and highlighting of elements uses 2x scaling instead of 3x so when hovering the tree the highlight indicator is offset by that scaling factor, e.g. x/y and and size of the rect is too small.

EDIT: ok, regarding the rect output in the Display section this is due to the hardwired const SCALE_FACTOR = 2; in Inspector.js#L23

For the highlighting it may be needed to adjust scale / scale_highlight in ide.js and take the Retina display scale factor into account

lambourn commented 7 years ago

While thinking about it: by using the width/height of the UIAApplication (which is the unscaled point size) and the original width/height of the screenshot (which is in pixel) you should be able to get the Retina scale factor to use for highlighting and display in the Display section.

mykola-mokhnach commented 7 years ago

Added a separate combo box, which makes possible to adjust scale factor manually (range is 1x-5x). The default scale factor equals to 2x and is preserved in the local storage once it is changed.

lambourn commented 7 years ago

very nice, thanks!