mapbox-gl-draw
mapbox-gl-draw copied to clipboard
map.on('draw.update', callback) does not fire consistently
mapbox-gl-js version: v0.39.1, v0.38.0, v0.37.0 mapbox-gl-draw version: v1.0.0, 0.19.0
Steps to Trigger Behavior
- Open Plunkr: https://plnkr.co/edit/Rn5AZKlDrdBBAQmdiRy2?p=preview
- Open Dev Tools -> Console
- Draw a polygon
- Update the polygon by moving a point
- Repeat step 4 and keep track of the number of times you have moved a point. After a few changes you should notice that the count variable does not represent the number of changes actually made.
Expected Behavior
The draw.update
event callback should fire each time a point is moved to a new position. Which in turn would increment the count variable by one.
Actual Behavior
The draw.update
event callback is not being fired consistently.
Opened plunker and received error:
api.mapbox.com/styles/v1/mapbox/streets-v9?access_token=pk.eyJ1Ijoic2t5d2F0Y2hhcHBzIiwiYSI6ImNpa3B4aHp6OTE1OWV0bm02aWQwOTd2OG8ifQ.Ic8z13iLo4r39I01ckGvZA Failed to load resource: the server responded with a status of 401 (Unauthorized)
Updated Plunker with new key. Sorry about that
moved different points about 20 times. all fired. may you clarify the scenario? may be screencast?
I have provided a screencast to better demonstrate the issue. You can skip to about 19 seconds in for the updating to start.
Here are a list of time codes for missed events: 0:22 - Between console log 3 & 4 0:26 - Between console log 5 & 6 0:28 - Between console log 6 & 7 0:36 - After console log 14
I hope that the screen capture better illustrates the issue. I am not sure how to provide more detail other than to share the screen capture and note that while I am able to easily reproduce the issue, there is no specific pattern observed for when the event doesn't fire.
Please let me know if the screen capture helped or if I can be of any more help in tracking down this bug. I appreciate the help
can not reproduce. just have guess that it due to some async operations. may be you move point before processing of previous event finished. I don't know MapBoxDraw internals. So it based only on experience. Also, try to update MapBoxDraw. Last version is 1.0.2
I am experiencing this as well, running on version 1.0.2 in Chrome 61.0.3163.100 for MacOS.
The issue seems to be intermittent and difficult to reproduce predictably. When it does happen, no draw.update
event is fired after a point is moved. The point, however, doesn't revert to its previous location (which might indicate that the event was never completed), but stays where it was dropped. No errors appear in the logs.
draw.update
is controlled by the modes so its a bit weird. Doing a quick search of UPDATE might help track down why this is happening.
I can confirm this issue as well. Works fine for me in Chrome but on mobile the draw.update
doesn't get fired a single time. For example the plunker from above with an alert instead of a console.log https://run.plnkr.co/JL2A9pK1sxpcsMjQ/ doesn't alert on mobile after draw.update
but does alert on a none mobile device.
Update: I think it only occurs when updating points. The event fires on line or polygon updates.
I am experiencing this issue as well, running version 1.0.4
of mapbox-gl-draw and 0.42.1
in Chrome 63.0.3239.84 on macOS Sierra (16G1036).
I'm able to reproduce it by creating a polygon in the plunkr in the original post, and then moving it around with my mouse. Every so often, the update event does not fire when I move the polygon.
I stumbled across this issue when testing the mobile browser side of things (desktop seemed consistent) and ran into the exact same scenario @bloigge described.
I ultimately ended up having to wrap my logic in a 'touchend' event and pass all my draw logic within.
I can reproduce the problem. It seems to happen in direct-select
mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad. Harder to reproduce with a mouse.
mapbox-gl-draw 1.0.9
mapbox-gl 0.44.2
I can reproduce this problem 100% of the time on an Android mobile device, and also in Chrome's mobile simulator. This is with the latest version of mapbox-gl-draw: 1.1.1, and version 0.51.3 of mapbox-gl.
Steps to reproduce:
- Draw polygon
- Click out of the polygon to leave edit mode
- Move the entire polygon
- The above step does not fire draw.update event
I have verified the problem on Chrome 66 and 72 on an Android device, and also Chrome 72 in the device simulator.
Important note: moving individual points does fire draw.update. The problem only exists when moving the entire shape.
I am also facing this issue on a macOS computer with a trackpad (Chrome).
I made a fork of the v1.4.1 with fix and prepare command. You can try it:
yarn add https://github.com/gynekolog/mapbox-gl-draw.git#119ebc511726e4a54ea1fd499c7ebd853a76ef22
yarn add https://github.com/gynekolog/mapbox-gl-draw.git#119ebc511726e4a54ea1fd499c7ebd853a76ef22
is this in "main" now? I'm still having this kind of issue...
@stepankuzmin I can reproduce the problem. It seems to happen in direct-select
mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.
mapbox-gl-draw 1.4.1 mapbox-gl 2.10.0
Hi @Maximenya,
We haven't yet released a new version of Mapbox GL Draw that includes this fix. Sorry for the inconvenience.
When will you release the fixed version? Why wait so long to release a bug fix?
hello, please tell me why when I install the latest version of your package there is no src folder but only dist. i can't update ''mapbox-gl-draw-freehand-mode'' under your update because of this
I tried locally to apply #1160 but I'm still able to reproduce the problem by following @Maximenya instructions:
@stepankuzmin I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.
Anyone else also facing this issue even after applying the fix?
I tried locally to apply #1160 but I'm still able to reproduce the problem by following @Maximenya instructions:
@stepankuzmin I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.
Anyone else also facing this issue even after applying the fix?
Same problem. Testing on v1.4.2
Wondering if anyone else is still experiencing this and if there's any fix for it? Thanks.
Works better, but still with problems on 1.4.3.