Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache session details to avoid making unnecessary queries #765

Closed
wants to merge 2 commits into from

Conversation

mykola-mokhnach
Copy link
Contributor

Change list

Addresses #764

Types of changes

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Copy link
Member

@SrinivasanTarget SrinivasanTarget left a comment

Choose a reason for hiding this comment

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

👍

@vrunoa
Copy link

vrunoa commented Nov 12, 2017

Works great! reduced a test from 2hs to 25minutes.

@saikrishna321
Copy link
Member

Wow, that's a great time difference .....

@saikrishna321
Copy link
Member

@vrunoa was this tested on parallel sessions ? if not I can take it ...

@vrunoa
Copy link

vrunoa commented Nov 12, 2017

@saikrishna321 no, just a test on a cloud service. I havent test parallel sessions, if you cant take it it would be great.

@saikrishna321
Copy link
Member

done I will do it today

*/
@SuppressWarnings("unchecked")
@Override
public synchronized Map<String, Object> getSessionDetails() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am against this change. Session details data is not immutable. It may change when driver is switched to another context (NATIVE APP or WEB VIEW).

I think the right way is to find places where it is invoked frequently.

Copy link

Choose a reason for hiding this comment

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

If full copy is used, shouldn't there at least be an 'expiry time' or a method to force the details to be refreshed?

When I ran into this issue I decided to use an expiry time, based on the time it took to retrieve the information, in my (not so nice) workaround in https://github.com/fhoeben/hsac-fitnesse-appium.
The approach I currently use there is to have some cache at the element level, and using my own 'json to element' converter.
My custom elements require less retrieval of session details (for me the 'foundBy' information does not require session details, which is currently required for the driver's toString(), and they 'cache' information retrieved from the driver about an element for a short while (so my test code does not need to worry too much about for instance checking isDisplayed() twice)).

@TikhomirovSergey
Copy link
Contributor

@vrunoa There are some question to make it clear:

  • do you use get session details frequently at the client side?
  • do you use page objects?

@vrunoa
Copy link

vrunoa commented Nov 13, 2017

@TikhomirovSergey the test I'm running is not calling to getSessionDetails.
If the session will change at some point, should be getSessionDetails only at that point and not every time ?

Not sure about page object, can you help me figure out if it is used.

@saikrishna321
Copy link
Member

@vrunoa as my tests are running locally, i don't see much time difference its 2mins difference in total

@vrunoa
Copy link

vrunoa commented Nov 14, 2017

@saikrishna321 yeah, the big difference it's when running on a cloud service since those getSessionDetails calls take like 5 seconds or more between commands but locally you just lose a few milliseconds.
@TikhomirovSergey do we know where are session details changed ?

@TikhomirovSergey
Copy link
Contributor

@vrunoa I suppose we don't all the actions which can change session parameters.
I know one driver.context(someContext)

If the session will change at some point, should be getSessionDetails only at that point and not every time ?

We know only one place in java_client where getSessionDetails is asked very often. And I am going to optimize it. I have asked the question before. Does your code build and use page objects using @AndroidFindBy /@iOSFindBy etc and AppiumFieldDecorator? Otherwise could you show the sample of your code which has the performance issue?

@vrunoa
Copy link

vrunoa commented Nov 14, 2017

@TikhomirovSergey yes, it does use those decorators. Sorry but I cannot share the source code of this particular test.

@TikhomirovSergey
Copy link
Contributor

@vrunoa ok. So it seems I was right. Working on improvements.

@vrunoa
Copy link

vrunoa commented Nov 14, 2017

thanks @TikhomirovSergey. Let me know if there's something I can help with.

@vrunoa
Copy link

vrunoa commented Nov 16, 2017

@TikhomirovSergey Sorry to bother, but do you have any updates on this fix?

@TikhomirovSergey
Copy link
Contributor

@vrunoa Yep. Please look at the related issue #764. There are 3 commits. Tomorrow I am going to propose the new PR.

@TikhomirovSergey TikhomirovSergey mentioned this pull request Nov 17, 2017
4 tasks
@mykola-mokhnach
Copy link
Contributor Author

Closed in favour of #769

@mykola-mokhnach mykola-mokhnach deleted the cache_session branch December 19, 2017 19:48
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.

6 participants