Select to view content in your preferred language

Performance problem with SketchViewModel

640
6
12-05-2022 05:29 AM
ArneDahlman
New Contributor III

Hello!

I have a problem with SketchViewModel.

We are using SketchViewModel for our custom edit tool. (mode='click')

When I draw a polygon quickly, the SketchViewModel doesn't seem to keep up.
I need to wait for the draw line to "reach the mouse cursor", otherwise there will be a pan instead, and no point is drawn.

I have tried to disable pan by calling stopPropagation() on the drag event. But even with no pan the problem still remains. No points will be drawn if I draw to quickly.

You can observe the same behavior in this sample (version 4.25)
https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/

In freehand mode the there is no problem, but our users don't want to use frehand mode.
They want every click resulting in exactly one point.

Is this a bug in the SketchViewModel or am I missing some functionality here?

Anyone know how I can solve this?


Thanks
Arne Dahlman

 

JS-api: 4.24

CPU: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz 2.30 GHz

Browsers:
Edge Version 107.0.1418.62
Chrome Version 107.0.5304.122

0 Kudos
6 Replies
BryanMc
Occasional Contributor

Have you tried to disable the map navigation settings when the user initiates drawing? The mapview has a navigation object you could update to disable certain navigation features (just make sure to enable again on create when event.state 'complete').

mapview.navigation.browserTouchPanEnabled = false;

 

 

 There are a few more navigation features you could also play with if needed.

0 Kudos
ArneDahlman
New Contributor III

Hi Bryan

Thank you for your response!

I tried what you suggested, but it didn't work.
Maybe browserTouchPanEnabled only affects touch events. I am using a mouse.

I also did try to set momentumEnabled & gamepad.enabled to false, but that didn't help either.

0 Kudos
BryanMc
Occasional Contributor

I opened the original sample and had the same issue with mouse events. Below seems to work - although if you are moving the mouse too fast it still doesn't "click" to add a vertex - but it does disable pan during the draw process for whatever draw type you are interested in:

let stopPan = false;
view.when(() => {
    sketch.watch("activeTool", (newValue, oldValue, property, object) => {
	//determine tools you want to disable Pan for
        if (["point", "polyline", "polygon"].includes(newValue)) {
            stopPan = true;
        } else {
            stopPan = false;
        }
    });
    view.on("drag", (event) => {
        if (stopPan) {
            event.stopPropagation();
        }
    });
});

  

0 Kudos
ArneDahlman
New Contributor III

Yes disabling the drag-event in the mapView prevents the map from moving around when drawing. This is a good thing.

Hovever, as you said, it doesn't prevent the problem that not every mouse click adds a vertex when drawing.

I think the problem is that the Sketchviewmodel still handles the drag events, even if there is no pan i the map.

0 Kudos
GILBERTNG1
New Contributor III

We are running into the same issue when upgrading from 4.26 to 4.29 JS API, and it is holding up our upgrade to 4.29. The frame rate on SketchViewModel and Draw is simply unacceptable in 4.29 when using it to create custom tools that draw polylines and polygons. 

To demonstrate this, change lines 11-12 in this ESRI JS example to 4.26, and then press the refresh button on the top-right of the page. The frame rate seems to be very slow, even on a newer Windows PC with a 13th gen Intel i7 CPU. However, the out-of-the-box Sketch widget does not have this issue. 

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=sketch-viewmodel-styler 

0 Kudos
GILBERTNG1
New Contributor III

@ArneDahlman As an update, we were only able to replicate your issue in 4.29, using Chrome + Windows remote desktop RDP at 4K resolution. Zero issues in Edge web browser, RDP or not. Zero issues in Chrome when RDP is at 1080P display resolution. 

0 Kudos