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

Canonicalize tile url #7594

Merged
merged 5 commits into from
Nov 26, 2018
Merged

Canonicalize tile url #7594

merged 5 commits into from
Nov 26, 2018

Conversation

mollymerp
Copy link
Contributor

close #7400

This PR does a couple 🆕 things to improve parity between gl-native and gl-js:

  • adds setter and getter for config.API_URL
  • transforms tile URLs to use the config.API_URL if using a mapbox:// url, like the rest of the assets requested by the library

this is technically changing existing behavior, but it shouldn't be breaking, unless a user was creating their own TileJSON endpoint to respond with an object where the tiles urls were from a different domain than the TileJSON/other assets 😬 🙏 So I guess it maybe technically is breaking?

Also, as far as I know the reason for providing multiple urls like a.tiles.mapbox.com, b.tiles.mapbox.com was to workaround the max open connections the browser will allow for any given origin for HTTP 1.0. When profiling locally on a large monitor, I do notice that some tiles requests are queued briefly (~10-50ms) when many tiles are being requested at once, but I'm not noticing a real big in time to first render (TTFR) or zoom/pan performance. @kkaefer any thoughts on how we should verify this?

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mollymerp
Copy link
Contributor Author

Here are the benchmark results. I didn't notice anything unusual, and really wouldn't expect to since the benchmarks don't actually request many tiles.

![screencapture-localhost-9966-bench-versions-2018-11-15-16_30_01](https://user-images.githubusercontent.com/2425307/48590304-34339b00-e8fc-11e8-80f3-e145b5fd2881.png)

for (let i = 0; i < params.length; i++) {
if (params[i].indexOf('access_token=tk.') === 0) {
params[i] = `access_token=${config.ACCESS_TOKEN || ''}`;
export const canonicalizeTileURL = function(url: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be an arrow function I think. Same in line 135.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

following convention here.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I thought maybe that was the case. Good to know.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think the convention is export function fn(...), not export const fn = function(...). So this looks like a pre-existing omission.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I was following convention of the functions in this file – do you want me to change all of them ?

src/util/mapbox.js Outdated Show resolved Hide resolved
src/util/mapbox.js Outdated Show resolved Hide resolved
src/util/mapbox.js Outdated Show resolved Hide resolved
src/util/mapbox.js Show resolved Hide resolved
src/util/mapbox.js Outdated Show resolved Hide resolved
@mollymerp mollymerp added breaking change ⚠️ Requires a backwards-incompatible change to the API GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform labels Nov 26, 2018
@mollymerp mollymerp merged commit c78fa7a into master Nov 26, 2018
@mollymerp mollymerp deleted the canonicalize-tile-url branch November 26, 2018 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ Requires a backwards-incompatible change to the API GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"canonicalize" tile urls from TileJSON so they use config.API_URL
5 participants