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 OpenStreetMap tiles not rendering under Chrome #787

Merged
merged 2 commits into from Mar 22, 2022

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Mar 21, 2022

Fix #786

Basically, the problem was from trying to use http URLs when possible. Just use https everywhere.


I've also changed a bunch of external URLs that were used in examples; now using https wherever possible. A couple of URLs needed to change altogether (e.g. webmap.arcticconnect.org became webmap.arcticconnect.ca) and I removed one example that used an image from rstudio.com that's gone now.

There's one more example that doesn't work: #788, but after spending a couple of hours on it I couldn't figure it out. I'd like to leave it for now and get the current release out, since the issue this PR does fix is so severe.

PR task list:

  • Update NEWS
  • Add tests (where appropriate)
    • R code tests: tests/testthat/
    • Visual tests: R/zzz_viztest.R
  • Update documentation with devtools::document()

Testing notes

Run this in RStudio:

library(leaflet)
leaflet() %>% addTiles()

It should look fine in RStudio, but if you pop it out to an external browser and that browser is Chrome, at least for me it comes up grey. Showing the JS console reveals tons of 403 errors for requests to tile.openstreetmap.org. I have to caveat this by saying this all depends on user agent heuristics, so it's possible it won't reproduce on your machine.

With the changes in this PR, it looks fine everywhere.

When rendering under http:// with Chrome, openstreetmap.org would redirect
us to https://, and something about that caused Chrome to send different
headers than if we went directly to https:// originally. Specifically, the
Sec-CH-UA header would not be included, and it looks like openstreetmap's
anti-abuse filters now treat a Chrome UA without Sec-CH-UA as suspicious
(just guessing based on what I'm seeing).

My user agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36

My Sec-CH-UA:
" Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"'
@jcheng5 jcheng5 requested a review from schloerke March 21, 2022 23:45
Copy link
Contributor

@schloerke schloerke left a comment

Choose a reason for hiding this comment

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

Url changes look great.

I remember we did this because of Linux on IDE.

If they are ok to have https, then all of this is awesome. If they can not visualize https in the IDE on Linux, then we will have problems.

@jcheng5
Copy link
Member Author

jcheng5 commented Mar 22, 2022

I think it was, like, Linux on Red Hat 5 😆

@jcheng5
Copy link
Member Author

jcheng5 commented Mar 22, 2022

I can at least confirm that it works on Ubuntu 20.04. If someone out there still needs http, I think it just means they will have to provide the URL manually.

@jcheng5 jcheng5 merged commit 00e053b into main Mar 22, 2022
@jcheng5 jcheng5 deleted the joe/bugfix/osm-tiles branch March 22, 2022 03:33
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.

OpenStreetMap tiles not rendering in some circumstances
2 participants