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

Fix double counting of createImageBitmap requests in RequestScheduler #8163

Merged
merged 11 commits into from
Jan 14, 2020

Conversation

tephenavies
Copy link
Contributor

A potential fix to #8162.

@cesium-concierge
Copy link

Thank you so much for the pull request @steve9164! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

  • ❌ Missing CONTRIBUTORS.md entry.
  • ❌ Missing CLA.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@kring
Copy link
Member

kring commented Sep 16, 2019

@steve9164 is a member of my team and is covered by our CLA.

@OmarShehata
Copy link
Contributor

Thanks for confirming that Kevin, we added Stephen to Data61's corporate CLA.

@hpinkos
Copy link
Contributor

hpinkos commented Sep 18, 2019

@steve9164 please merge in master

@tephenavies
Copy link
Contributor Author

Merged!

@hpinkos
Copy link
Contributor

hpinkos commented Sep 20, 2019

@tfili or @OmarShehata could you review?

Resource._Implementations.createImage = function(url, crossOrigin, deferred) {
expect(url.indexOf('.tif?cesium=true')).toBeGreaterThanOrEqualTo(0);
Resource._Implementations.createImage = function(request, crossOrigin, deferred) {
expect(request.url.indexOf('.tif?cesium=true')).toBeGreaterThanOrEqualTo(0);

// Just return any old image.
Resource._DefaultImplementations.createImage(imageUrl, crossOrigin, deferred);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't all the Resource._DefaultImplementations.createImage calls in the tests now take request? There are a bunch spread throughout the tests.

Copy link
Contributor Author

@tephenavies tephenavies Sep 26, 2019

Choose a reason for hiding this comment

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

You're right.

@tephenavies
Copy link
Contributor Author

I've fixed the tests and I think this is ready for another review. I think the CI error is not due to my changes, since it comes from loadImageElement/image.onerror@Source/Core/Resource.js, so it sounds like the image failed to load somehow before reaching my changes.

@tephenavies
Copy link
Contributor Author

Tests pass now and the new ES6 changes have been merged in. I think this is a pretty big issue. At the moment any Cesium app running on a version of Chrome that supports createImageBitmap will issue only 3 simultaneous requests for image tiles per domain.

@OmarShehata
Copy link
Contributor

At the moment any Cesium app running on a version of Chrome that supports createImageBitmap will issue only 3 simultaneous requests for image tiles per domain.

This is still true with this PR, it's just not counting them anymore, right?

@tephenavies
Copy link
Contributor Author

With this PR an image request will correctly be counted as 1 request (instead of 2), so Cesium's default request limit of 6 per domain will be correctly applied, instead of Cesium incorrectly limiting to 3 real requests.

Here are some screenshots from Chrome running my changes and running the current Cesium. I set Chrome to throttle requests (added a 4000ms latency so that the number of in-flight requests was obvious), used Stamen Watercolour map (because it uses the createImageBitmap code in Chrome) and panned around to request new tiles. (Note that stamen watercolour loads from multiple subdomains, but I'm just looking at requests to 1 subdomain, because there should be a max of 6 to each subdomain, but there isn't)

On http://localhost:8080/Apps/CesiumViewer/index.html with my changes:
image

On https://cesiumjs.org/Cesium/Apps/CesiumViewer/index.html:
image

In the first there are 6 concurrent requests (which is correct) and the second screenshot shows only 3 concurrent requests due to the double counting issue.

@OmarShehata
Copy link
Contributor

Thanks for the explanation @steve9164. I wasn't thinking about how overcounting was interfering with the request scheduler's throttling. We should definitely try to get this fix in this upcoming release since it sounds like this is slowing down imagery loading.

@cesium-concierge
Copy link

Thanks again for your contribution @steve9164!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

2 similar comments
@cesium-concierge
Copy link

Thanks again for your contribution @steve9164!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

@cesium-concierge
Copy link

Thanks again for your contribution @steve9164!

No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy?

I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with @cesium-concierge stop. If you want me to start again, just delete the comment.

@kring
Copy link
Member

kring commented Jan 13, 2020

If I don't hear any complaints, I'm going to edit this lightly (e.g. sync with master) and then merge it. Probably today. It makes Cesium load imagery twice as fast. 🐎

@kring kring merged commit 9082fc6 into CesiumGS:master Jan 14, 2020
@kring kring deleted the fix-double-counting-upstream branch January 14, 2020 15:40
@kring
Copy link
Member

kring commented Jan 14, 2020

Thanks @steve9164, sorry this took so long to merge!

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