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 events being fired after Map#remove has been called when the WebGL context is lost and restored (#726) #727

Merged
merged 2 commits into from
Dec 22, 2021

Conversation

vanilla-lake
Copy link
Contributor

Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (#726)

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Write tests for all new functionality.
  • Manually test the debug page.
  • Add an entry inside this element for inclusion in the maplibre-gl-js changelog: <changelog></changelog>.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2021

Bundle size report:

Size Change: +17 B
Total Size Before: 194 kB
Total Size After: 194 kB

Output file Before After Change
maplibre-gl.js 185 kB 185 kB +17 B
maplibre-gl.css 9.49 kB 9.49 kB 0 B
ℹ️ View Details
Source file Before After Change
rollup/build/tsc/src/ui/map.js 6.07 kB 6.08 kB +14 B

src/ui/map.ts Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Dec 22, 2021

Thanks for taking care of the code review changes.
I think this code is OK as it removed handler on map remove which is probably the right thing to do.
In the issue related to this PR you mentioned something about "move" being fired after context is restored.
While I'm not sure I fully understand the scenario, I don't see any reference to "move" in the tests you added or in the code. Am I missing something?

@vanilla-lake
Copy link
Contributor Author

No worries! 😃 _contextRestored, in addition to firing the "webglcontextrestored" event directly, calls resize, which may fire the movestart, move, moveend and resize events. I didn't want to clutter the tests with all these events, but I can add them if you think it might be better.

The idea is that by removing _contextRestored from the listeners for the canvas' "webglcontextrestored" event, no action should be taken by the map when the context is restored.

@HarelM HarelM merged commit d375def into maplibre:main Dec 22, 2021
@wipfli wipfli mentioned this pull request Dec 26, 2021
9 tasks
davenquinn added a commit to davenquinn/maplibre-gl-js that referenced this pull request Dec 29, 2021
* main: (98 commits)
  [Jest] Migrate `geojson_worker_source.test.js` (maplibre#731)
  Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (maplibre#726) (maplibre#727)
  Define return type of getSource as possibly undefined (maplibre#724)
  Fix attibution controll (maplibre#668)
  Fix start-debug to watch ts files (maplibre#704)
  [Jest] Migrate `touch_zoom_rotate.test.js` (maplibre#721)
  [Jest] Migrate `requestRenderFrame.test.js` (maplibre#722)
  [Jest] Migrate `scroll_zoom.test.js` (maplibre#712)
  [Jest] Migrate `marker.test.js` (maplibre#696)
  [Jest] Migrate `mouse_rotate.test.js` (maplibre#711)
  [Jest] Migrate `keyboard.test.js` (maplibre#707)
  [Jest] Migrate `map_event.test.js` (maplibre#710)
  [Jest] Migrate `drag_rotate.test.js` (maplibre#709)
  Handle spies and call counts (maplibre#708)
  [Jest] Migrate `drag_pan.test.js` (maplibre#702)
  Add type for styleimagemissing event (maplibre#703)
  Fix MapDataEvent#isSourceLoaded being true in GeoJSONSource "dataloading" event handlers (maplibre#694) (maplibre#695)
  [Jest] Migrate `dblclick_zoom.test.js` (maplibre#697)
  [Jest] Migrate `popup.test.js` (maplibre#687)
  Fixed typo (maplibre#698)
  ...
@vanilla-lake vanilla-lake deleted the contextrestored branch January 28, 2022 15:17
davenquinn added a commit to davenquinn/maplibre-gl-js that referenced this pull request Feb 9, 2022
* pluggable-render: (102 commits)
  WIP - pluggable render update
  Removed a badly typed variable
  [Jest] Migrate `geojson_worker_source.test.js` (maplibre#731)
  Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (maplibre#726) (maplibre#727)
  Define return type of getSource as possibly undefined (maplibre#724)
  Fix attibution controll (maplibre#668)
  Fix start-debug to watch ts files (maplibre#704)
  Filter out hillshade layers
  Filter out hillshade styles
  [Jest] Migrate `touch_zoom_rotate.test.js` (maplibre#721)
  [Jest] Migrate `requestRenderFrame.test.js` (maplibre#722)
  [Jest] Migrate `scroll_zoom.test.js` (maplibre#712)
  [Jest] Migrate `marker.test.js` (maplibre#696)
  [Jest] Migrate `mouse_rotate.test.js` (maplibre#711)
  [Jest] Migrate `keyboard.test.js` (maplibre#707)
  [Jest] Migrate `map_event.test.js` (maplibre#710)
  [Jest] Migrate `drag_rotate.test.js` (maplibre#709)
  Handle spies and call counts (maplibre#708)
  [Jest] Migrate `drag_pan.test.js` (maplibre#702)
  Add type for styleimagemissing event (maplibre#703)
  ...
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.

2 participants