这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@vinaykumar0339
Copy link

@vinaykumar0339 vinaykumar0339 commented Mar 31, 2025

This PR introduces a new inDepthSnapshot flag that provides flexibility in retrieving the iOS UI hierarchy faster.

  • When requesting the page source in JSON format (useJSONSource = true), this appium capability setting inDepthSnapshot allows users to control whether to take an in-depth snapshot or a faster, lightweight snapshot.
  • By setting inDepthSnapshot to false, users can improve performance when retrieving the UI hierarchy by skipping deep snapshots.
  • If not explicitly set, the default behavior ensures in-depth snapshots are enabled for detailed UI extraction.

How to use it
image

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 31, 2025

CLA Signed

  • ✅login: vinaykumar0339 / (2f3dc6e)

The committers listed above are authorized under a signed CLA.

- (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *)excludedAttributes
{
id<FBXCElementSnapshot> snapshot = [self fb_takeSnapshot:YES];
id<FBXCElementSnapshot> snapshot = [self fb_takeSnapshot:[FBConfiguration inDepthSnapshot]];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this is supposed to work. setting this argument to NO makes the snapshotting function to not return the children property, which renders the recursive tree fetching impossible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach
The fb_takeSnapshot function allows passing inDepth: NO.

[self snapshotWithError:&error]

According to the official documentation, this method retrieves the entire hierarchy, including child elements.

I compared the results of passing YES and NO to inDepth, and both responses appear identical.

with YES parameter:
image
with No Parameter:
image

I also ran a diff check, and it showed no differences:
image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this trick only works for root/application elements. Let me test it locally.
Could you also provide performance comparison results?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach
Is time comparison metrics enough?

Copy link
Author

@vinaykumar0339 vinaykumar0339 Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach
💡 Performance Summary:
With visible attribute (default):

inDepth=true: ~15s
inDepth=false: ~11s
With visible attribute excluded (appiumpageSourceExcludedAttributes: "visible"):
inDepth=true: ~3s (5× faster)
inDepth=false: ~0.5s (22× faster)

Yes, performance varies depending on the screen complexity. Using inDepth=false with excluded visible attributes can bring the page source API response time down to under 1 second in most cases.
The main motivation for this optimization in WebDriverAgent is to support a new library for the Appium ecosystem that will provide more generic element finding capabilities. This library will use element coordinate information (x,y bounds) to implement relative positioning strategies like "left of text", "right of text", "below", "above", etc.
We can make these spatial element-finding strategies much more efficient by improving the page source retrieval performance.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say in case this snapshotting strategy really improves the performance then there is no point in putting it under a flag. Lets make it the default setting instead. @vinaykumar0339 Please check if #998 works for you

Copy link
Author

@vinaykumar0339 vinaykumar0339 Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach Yes, this change (#998) works for me as well since it uses:

[self snapshotWithError:&error]

May I ask when this change could be pushed along with Appium? (https://github.com/appium/appium-xcuitest-driver/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published in the xcuitest driver 9.1.3+

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mykola-mokhnach for the quick response and for considering my suggestion! Appreciate the effort in creating a new version based on it. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants