mapbox / mapbox/mapbox-gl-js

Transform css makes the map crash the whole page

Open
#12,148 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

We render a map on a slide that can be landscape or portrait. For portrait mode we don't have specific css but for landscape mode we add `transform: rotate(-90deg) translateX(X) translateY(Y);` and mapbox crashes the page with this.

**mapbox-gl-js version**: 2.8.1

**browser**: Chrome

### Steps to Trigger Behavior
1. Open the CodeSandbox
2. Page crashes

### Link to Demonstration
If you comment `transform: rotate(-90deg) translateX(-120px) translateY(-120px);` from App.scss then refresh the page the map renders. Now uncomment the css and see that it renders the map but if you hover over it is gonna throw an error `Invalid LngLat object: (NaN, NaN)`. After that refresh the page again and is gonna crash.

So if we have the css when mapbox loads it crashes the page and if we add it after the map renders it throws an error.
[CodeSandbox](https://codesandbox.io/s/mapbox-crash-70vqzv?file=/src/App.scss)

### Expected Behavior
The map renders and works normally.

### Actual Behavior
The map crashes the page or throws an error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure in the linked CodeSandbox, starting with the transform rule in App.scss. Compare loading the map with the rule present versus adding it after render, then follow the hover path that reports `Invalid LngLat object: (NaN, NaN)`. Done means the map renders and remains usable in landscape mode without crashing or throwing on hover.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.