mapbox / mapbox/mapbox-gl-js

Mapbox style diff testing produce too many changes in diff

Open
#8,298 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation :mag:
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.