Mapbox style diff testing produce too many changes in diff
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 0.52.0
**browser**: Chrome
### Steps to Trigger Behavior
1. Load style with deprecated properties (like "is-stroke")
2. Rebuild exactly same style
3. Diff failing on perform update on deprecated properties and rebuilding style from scratch
### Expected Behavior
Style update should not detect any changes and especially failing on deprecated properties
### Actual Behavior
Mapbox setStyle(nextStyle, { diff: true}) fail to in some scenarios when original style contains some deprecated properties, even when style not changed at all
This is happening because of [diffStyle](https://github.com/mapbox/mapbox-gl-js/blob/master/src/style/style.js#L435) takes for a diff this.serialize(), which is a modified ([_loadJson](https://github.com/mapbox/mapbox-gl-js/blob/master/src/style/style.js#L217)) version of the original style, and comparing it with not pre-processed nextState.
This diff produces thousands of changes, even if style not modified at all.
I see a couple of options to fix this issue:
- process nextState and pass serialize version of it into diffStyles method
or
- pass this.stylesheet into diffStyles instead this.serialize(), because this.stylesheet contains original version of previously passed style
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with diffStyle in src/style/style.js around line 435 and the _loadJson path around line 217, then trace how setStyle(nextStyle, { diff: true }) compares the existing and next styles. Reproduce the deprecated-property case with the provided steps; done means rebuilding an unchanged style produces no changes and does not fail on deprecated properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100