You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ios): implement proper device pixel ratio detection (#1257)
* feat(ios): implement proper device pixel ratio detection
Replace hardcoded scale=1 with real device pixel ratio from WebDriverAgent API.
- Add getScreenScale() method to IOSWebDriverClient using /wda/screen endpoint
- Add getDevicePixelRatio() method to IOSDevice for consistent DPR detection
- Update getScreenSize() to use real scale instead of hardcoded value
- Improve fallback values from scale 1 to scale 2 (more typical for iOS)
- Add iOS-specific terms to dictionary for spell check
This aligns iOS implementation with Android's approach of getting real DPR
from system APIs, ensuring accurate coordinate calculations for different
device densities.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(ios): streamline device pixel ratio retrieval and error handling
* perf(ios): cache device pixel ratio to avoid repeated API calls
Optimize device pixel ratio handling by:
- Add devicePixelRatioInitialized flag to cache the value
- Implement initializeDevicePixelRatio() method for one-time initialization
- Call initialization in getScreenSize() to ensure it's cached
- Update description to use the correct scale value
This prevents repeated calls to WebDriverAgent /wda/screen endpoint
and improves performance, following the same pattern as Android implementation.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* perf(android): cache device pixel ratio to avoid repeated ADB calls
Optimize Android device pixel ratio handling by:
- Add devicePixelRatioInitialized flag to cache the DPR value
- Implement initializeDevicePixelRatio() method for one-time initialization
- Call initialization in size() method to ensure it's cached
- Remove repeated getDisplayDensity() calls from size() method
This prevents expensive ADB shell commands (dumpsys display) from being
executed on every size() call, significantly improving performance.
The getDisplayDensity() method involves complex regex parsing and multiple
shell commands, making caching essential for good performance.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(ios,android): throw error when device pixel ratio detection fails
Remove safe default values and throw errors when DPR detection fails to:
- Make device configuration issues visible immediately
- Prevent silent failures that could lead to coordinate calculation errors
- Ensure proper device setup before automation begins
Changes:
- iOS: Remove fallback to scale=2, throw error if WebDriverAgent API fails
- Android: Remove try-catch wrapper in initializeDevicePixelRatio()
- Both platforms now fail fast when DPR cannot be determined
This ensures coordinate calculations are always based on accurate device
information rather than potentially incorrect default values.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor(android): remove unnecessary coordinate conversion and image resizing
Remove redundant operations that were converting between physical and logical pixels:
- Remove reverseAdjustCoordinates() method and its usage in size()
- Return physical pixel dimensions directly from size() method
- Remove resizeAndConvertImgBuffer() from screenshotBase64()
- Remove unnecessary width/height parameters from screenshot method
- Remove unused import resizeAndConvertImgBuffer
The Android screenshot is already in physical pixels, and coordinate conversion
is handled by adjustCoordinates() when needed for touch operations. This
simplifies the code and avoids double conversions that could introduce errors.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(android): restore logical pixel coordinate system for accurate touch
Fix coordinate system to ensure accurate touch operations:
- Convert physical pixels to logical pixels in size() method
- Return logical dimensions that users expect (width/dpr, height/dpr)
- adjustCoordinates() converts logical coordinates to physical pixels for touch
- This maintains the expected coordinate system where user coordinates match screen dimensions
Without this fix, touch coordinates were being double-scaled since size()
returned physical pixels but adjustCoordinates() was still scaling them up.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(playground): update NavActions props to disable tooltip and model name display
* test(ios): update unit tests for new device pixel ratio implementation
Update iOS device tests to match the new DPR detection implementation:
- Add getScreenScale mock method returning scale=2
- Update expected DPR from 1 to 2 in all size() assertions
- Add getScreenScale mock to additional test setups
- Update test comments to reflect new DPR source
Tests now correctly validate that device pixel ratio is obtained from
WebDriverAgent's /wda/screen endpoint rather than being hardcoded.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix(ios): simplify device pixel ratio initialization and error handling
* fix(ios): replace error throwing with assertions for element location and device state
---------
Co-authored-by: Claude <[email protected]>
0 commit comments