Skip to content

Tune element UID generation - #65

Merged
mykola-mokhnach merged 5 commits into
masterfrom
new_uid
Mar 29, 2018
Merged

Tune element UID generation#65
mykola-mokhnach merged 5 commits into
masterfrom
new_uid

Conversation

@mykola-mokhnach

Copy link
Copy Markdown

The idea is based on facebookarchive#897 by @qmfrederik. The change allows to nicely optimise the size of the internal cache.

int processId = element.processIdentifier;
uint8_t b[16] = {0};
memcpy(b, &elementId, sizeof(long long));
memcpy(b + sizeof(long long), &processId, sizeof(int));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was thinking about this yesterday; perhaps you want to assert that sizeof(long long) + sizeof(int) < 16, although that's guaranteed to be the case on 32-bit and 64-bit platforms.

@qmfrederik

Copy link
Copy Markdown

Looks good to me - thanks for picking this up!

To recap, XCUITest uses 'proxy' objects which point to the actual UI elements. Every time you query for an element, you get new proxy objects - even if they point to the same underlying UI element.

This PR changes the algorithm which assigns UUIDs to XCUIElements so that it is 'deterministic' - in that two XCUIElements which point to the same UI element will have the same UUID.

This will have a positive impact on the element cache size - querying the same element 1000 times would result in ~125MB memory consumption in the current WebDriverAgent implementation; with this fix the memory consumption is reduced to ~25MB.

Together with the ideas discussed in in facebookarchive#896, this should seriously reduce the memory consumption of the element cache.

Mykola Mokhnach added 2 commits March 28, 2018 22:58
…o new_uid
# Conflicts:
#	WebDriverAgentLib/Routing/FBElementCache.m
@mykola-mokhnach

mykola-mokhnach commented Mar 29, 2018

Copy link
Copy Markdown
Author

@qmfrederik Can you please help to update cache unit tests after merge?

https://travis-ci.org/appium/WebDriverAgent/jobs/359731836

@mykola-mokhnach

Copy link
Copy Markdown
Author

nwm, I've figured it out myself: d7061da

@mykola-mokhnach
mykola-mokhnach merged commit f91ef71 into masterMar 29, 2018
@mykola-mokhnach
mykola-mokhnach deleted the new_uid branch March 29, 2018 14:56
Sign up for freeto 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.

3 participants

@mykola-mokhnach@qmfrederik@imurchie