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

avoid incomplete webp support in Edge 18 #7687

Merged
merged 5 commits into from
Dec 12, 2018
Merged

avoid incomplete webp support in Edge 18 #7687

merged 5 commits into from
Dec 12, 2018

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Dec 11, 2018

Edge 18 supports WebP but not uploading WebP images to gl textures. Avoid this bug by testing support for this before enabling WebP loading.

fix #7671

The one downside of this approach is that once per page load we create a gl context and throw it away. I haven't seen this be a problem though. We could wait until a map is initialized and use that context but that would be more complex.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • manually test the debug page

We can't add automated testing because we don't do any of that in Edge. Manually testing the satellite map example does test this.

Copy link
Contributor

@asheemmamoowala asheemmamoowala left a comment

Choose a reason for hiding this comment

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

@ansis This approach makes every browser pay the price for the check that only the Edge browser really needs. To mitigate the cost on document load (that would affect TTFR ever so slightly), could this supportsWebp be exported as a function and the support value cached after the first call?

It would also mean that if there are any issues with webgl context creation, they do not surface in this code.

@ansis
Copy link
Contributor Author

ansis commented Dec 11, 2018

I reworked the implementation to avoid creating a context and instead using the one already created for a map. That is slightly better but the implementation is more complex in order to properly deal with asynchness.

@ansis This approach makes every browser pay the price for the check that only the Edge browser really needs.

Yep, the goal is to avoid user agent sniffing and instead check for the capability.

could this supportsWebp be exported as a function and the support value cached after the first call?

In the first implementation the function gets run as soon as the mapbox-gl-js script gets loaded (once per page load). In the new implementation it gets run on map creation (to avoid creating it's own context). Is this what you meant?

It would also mean that if there are any issues with webgl context creation, they do not surface in this code.

Yep, this needs to change! I've changed it in the latest commit.

@ansis
Copy link
Contributor Author

ansis commented Dec 11, 2018

@ChrisLoer would it be possible to get a gut review from you? Does e88ecae or the current HEAD of the branch seem like a better way to check for webp support?

@asheemmamoowala
Copy link
Contributor

In the first implementation the function gets run as soon as the mapbox-gl-js script gets loaded (once per page load). In the new implementation it gets run on map creation (to avoid creating it's own context). Is this what you meant?

I was thinking more that it would be a function that is invoked when needed by the usage in mapbox.js#normalizeTileURL. This method, from what I can tell is called from loadTIle on the main thread before passing to a worker. So there shouldn't be any synchronization issue with the way we use it.

@ChrisLoer
Copy link
Contributor

Does e88ecae or the current HEAD of the branch seem like a better way to check for webp support?

I don't have a strong opinion. Can you write a tiny benchmark to get an idea of the cost of the create context and texture upload check? My guess would be it's pretty trivial, in which case we might as well go with the e88ecae approach just because it's simpler. But the "do it with the gl context provided by setupPainter" approach doesn't seem too bad to me if there's any measurable performance win. Is there some tiny chance that while webpImgTest is loading, the GL context could be lost/restored, and then the test would fail from having stored the old context?

@ansis
Copy link
Contributor Author

ansis commented Dec 12, 2018

@asheemmamoowala I think I like keeping the test method separate from the way of accessing the result because otherwise we'd have to pass a gl context through to normalizeTileURL which seems a bit more invasive.

@ChrisLoer It looks like context creation is measurable but not that expensive. So keeping this approach? I added a context loss check to avoid that bug.

Copy link
Contributor

@ChrisLoer ChrisLoer left a comment

Choose a reason for hiding this comment

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

🍏

@ansis ansis merged commit 9cf6a0c into master Dec 12, 2018
@ansis ansis deleted the disable-webp-edge18 branch December 12, 2018 20:38
ansis added a commit that referenced this pull request Dec 12, 2018
katydecorah pushed a commit that referenced this pull request Jan 23, 2019
* publisher-production: (115 commits)
  fix inter-documentation link (#7791)
  [docs] use docs subdomain in examples (#7789)
  Bump Publisher
  First shot at new-domain staging
  [docs] Update page shell (#7760)
  updates API docs links to new url structure (#7757)
  add mapbox-gl-utils to plugins (#7752)
  [docs] Use docs-page-shell (#7742)
  Fixes bugs in documentation (#7741)
  Add worldviews example (#7720)
  Update compatibility matrix for `fill-extrusion-vertical-gradient` for ios & macos. (#7712)
  updates mapbox-gl-directions version in example (#7719)
  v0.52.0
  cherry-pick color state fix to release branch (#7715)
  Update location of drone video used in examples.
  v0.52.0-beta.2
  Cache hillshade textures based on texture size, not tile size. (#7695)
  avoid incomplete webp support in Edge 18 (#7687) (#7692)
  only align raster sources to pixel grid when map is idle to prevent shaking (#7426) (#7694)
  Flattens nested single element all expressions when converting to expressions (#7679)
  ...
katydecorah pushed a commit that referenced this pull request Jan 23, 2019
* publisher-production: (115 commits)
  fix inter-documentation link (#7791)
  [docs] use docs subdomain in examples (#7789)
  Bump Publisher
  First shot at new-domain staging
  [docs] Update page shell (#7760)
  updates API docs links to new url structure (#7757)
  add mapbox-gl-utils to plugins (#7752)
  [docs] Use docs-page-shell (#7742)
  Fixes bugs in documentation (#7741)
  Add worldviews example (#7720)
  Update compatibility matrix for `fill-extrusion-vertical-gradient` for ios & macos. (#7712)
  updates mapbox-gl-directions version in example (#7719)
  v0.52.0
  cherry-pick color state fix to release branch (#7715)
  Update location of drone video used in examples.
  v0.52.0-beta.2
  Cache hillshade textures based on texture size, not tile size. (#7695)
  avoid incomplete webp support in Edge 18 (#7687) (#7692)
  only align raster sources to pixel grid when map is idle to prevent shaking (#7426) (#7694)
  Flattens nested single element all expressions when converting to expressions (#7679)
  ...
katydecorah pushed a commit that referenced this pull request Jan 25, 2019
* initial layout

* clean up style spec layout

* clean up examples page

* fix links in style spec toc

* split style spec

* add examples landing page

* update plugins page layout

* format roadmap page

* fix icon positioning

* delete generated bench files

* address @mollymerp's feedback

* update dr ui version

* clean up console errors

* refactor page shell

* use docs-page-shell; update dr-ui and assembly; remove ProductDropdown

* fix spacing; add borderRadius

* various spacing, sizing

* remove additional space between h2  h3 siblings

* runs eslint --fix on component files

* remove unused lines; linting fixes

* navigation style updates: make link `link--gray` indent nested items

* add spacing to code blocks

* remove `color-gray` from non link elements

* api item + member styling

* remove base classes from /plugins; fix heading spacing

* use mr-ui copy-button in copyable.js

* run eslint --fix on docs/pages, docs/util

* linter fixes

* heading spacing for mobile

* rework copyable to use codesnippet

* add hover class to simple-map card

* make examples header consistent with other headers

* turn off h2 borders for the api section as they clash with the instance members toggle sections; max height and pretty scroll for code examples

* remove unused css

* adds hover state

* replace color-gray-light with color-gray; it's too light on white backgrounds

* remove padding conditional

* rm unused file

* break style-spec into components

* make tocnote link--gray

* adds back top padding to ApiItemMember

* set borderRadius on table rows

* readjust border on ApiItemMember

* adds txt-break-word to overflowing code blocks

* adds style spec to header

* light header adjustments

* style error note

* Merge branch 'publisher-production' into docs-redesign

* publisher-production: (115 commits)
  fix inter-documentation link (#7791)
  [docs] use docs subdomain in examples (#7789)
  Bump Publisher
  First shot at new-domain staging
  [docs] Update page shell (#7760)
  updates API docs links to new url structure (#7757)
  add mapbox-gl-utils to plugins (#7752)
  [docs] Use docs-page-shell (#7742)
  Fixes bugs in documentation (#7741)
  Add worldviews example (#7720)
  Update compatibility matrix for `fill-extrusion-vertical-gradient` for ios & macos. (#7712)
  updates mapbox-gl-directions version in example (#7719)
  v0.52.0
  cherry-pick color state fix to release branch (#7715)
  Update location of drone video used in examples.
  v0.52.0-beta.2
  Cache hillshade textures based on texture size, not tile size. (#7695)
  avoid incomplete webp support in Edge 18 (#7687) (#7692)
  only align raster sources to pixel grid when map is idle to prevent shaking (#7426) (#7694)
  Flattens nested single element all expressions when converting to expressions (#7679)
  ...

* update batfish, react, and react-dom

* rm unused module

* update mr-ui and github-slugger

* adds version var to OverviewHeader

* mb-pages -> publisher-production

* fix bool on iframe

* clean up page shell to fix build errors

* update/add pathname; add descriptions

* make toggles buttons for acessbility; increase hit box; make icon larger; do not change location on click

* use push state to change hash on click, but not to move page

* update dr-ui

* adds interactiveClass and sideBarColSize

* smaller sidebar on spec

* adds addtional padding to h3s on api page to clear the sticker

* make hit box larger for nav items on sidebard

* adjust topbarstick columns when `sidebarColSize` is set

* adds make-table-scroll plugin; make non markdown table scroll

* remove extra docs-content ids

* make table scroll; wrap code

* reorder tabs

* adds back to top button long pages

* update dr-ui

* sets unStickWidth on TopbarSticker

* Update batfish.config.js

* Update yarn.lock

* adds unit tests for examples

* fix tests

* add missing images

* adds test to make sure every example as a thumbnail image

* compress images

* resize thumbnail images to 1200 x 500

* compress again

* add a little wiggle room for image size

* updates documentation for tags and adds information about example thumbnail images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Studio Map won't render in Edge 2018 Release
3 participants