Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Issue 459 avoid page load blocks #460

Merged
merged 3 commits into from
Apr 23, 2019
Merged

Issue 459 avoid page load blocks #460

merged 3 commits into from
Apr 23, 2019

Conversation

ggalmazor
Copy link
Contributor

Closes #459

What has been done to verify that this works as intended?

I've used Chrome's inspector for all these tests with the "Disable cache" from the network tab enabled.

Version note blocking issues

  • Start Aggregate in localhost and verify that I get the "you're up to date" note.
  • Restart Aggregate, disable the network connection and verify that I get the "version check failed" note.

Google maps JS blocking issues

  • Start Aggregate and verify with the inspector that the script gets eventually loaded.
  • Restart Aggregate, disable the network connection and verify that I get an error but the page still loads.

Why is this the best possible solution? Were any other approaches considered?

First I tried to modify the client's JSNI implementation in LayoutUtils.java to handle errors related to the requests to GitHub's API, but I got to very complicated half-solutions due to conflicts between the blocking nature of GWT Java UI building and the asynchronous XMLHttpRequest.

Then I decided to switch to an all-Java server-side solution. At the expense of having a new GWT service, now we completely avoid client-side JSNI code and the asynchronous interaction is entirely made through GWT RPC calls, which is results in much simpler client code.

Thanks to moving this code to the server, we're also able to throttle-control calls to GitHub's API (and avoid nasty temporary bans due to spamming it with requests). Now, instead the clients (potentially many) doing calls to GH, it's the server who does 1 request per 24 hours max.

Are there any risks to merging this code? If so, what are they?

None.

Do we need any specific form for testing your changes? If so, please attach one

No.

Does this change require updates to documentation? If so, please file an issue at https://github.com/opendatakit/docs/issues/new and include the link below.

No.

- The version note depends on the latest version as reported by GitHub, which requires an HTTP request to their servers.
- This service takes care of the various scenarios that this request might create: HTTP interaction problems, temporal bans by GitHub (HTTP 403 response), parsing errors, etc.
- This service implements a 24 hour cache to prevent throttling issues.
  - Each client will make 5 or 6 requests in a row when loading (one for each view that needs the version note - see the browser's network inspector) and we don't want to create the same amount of requests to GitHub's API.
- We now use a new service that will return the full version note depending on the current deployed version and the latest available version as reported by GitHub (which refreshes every 24 hours)
- The main reason for this change is that Aggregate should be able to load without access to the internet.
- This required changing the XMLHttpRequest to run asynchronously and subscribing to the error events, but this conflicted with the blocking nature of GWT Java UI building and the complexities of JSNI interaction.
- By moving the interaction with GitHub to the server, we can simplify the client code (no JSNI, no asynchronous code issues).
- Now the google maps JS library loads asynchronously to prevent blocking the load page when the client doesn't have access to the internet.
@lognaturel
Copy link
Member

Moving the version check to the server seems great all around. 👍 Would be good to get a QA sanity check and ideally it can go in 2.0.3.

@kkrawczyk123
Copy link

Tested with success!

@opendatakit-bot unlabel "needs testing"
@opendatakit-bot label "behavior verified"

@ggalmazor ggalmazor merged commit dfe1f39 into getodk:master Apr 23, 2019
@ggalmazor ggalmazor deleted the issue_459_avoid_page_load_blocks branch April 23, 2019 13:36
This was referenced Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregate should not block page loads when network is down
4 participants