fix: detect iOS screen scale factor dynamically instead of hardcoding 3x#363
Open
haosenwang1018 wants to merge 2 commits intozai-org:mainfrom
Open
fix: detect iOS screen scale factor dynamically instead of hardcoding 3x#363haosenwang1018 wants to merge 2 commits intozai-org:mainfrom
haosenwang1018 wants to merge 2 commits intozai-org:mainfrom
Conversation
Replace the hardcoded SCALE_FACTOR = 3 with runtime detection that compares screenshot pixel dimensions against WDA's reported window size in points. The detected value is cached per WDA URL to avoid repeated queries. This fixes incorrect tap/swipe coordinates on non-3x devices such as iPhone SE (2x) and older iPads. Closes zai-org#311
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The iOS device module hardcodes
SCALE_FACTOR = 3to convert pixel coordinates to WDA point coordinates. This produces incorrect tap/swipe positions on non-3x devices (e.g. iPhone SE at 2x, older iPads at 2x).Relates to #311 (iOS coordinate calculation inaccuracy).
Solution
Replace the constant with a
_detect_scale_factor()function that:/window/sizeto get the screen width in pointsAll touch functions (
tap,double_tap,long_press,swipe) now use the dynamically detected factor.A public
get_scale_factor()accessor is also exposed for external use.Testing