facebook / Rapid

The OpenStreetMap editor driven by open data, AI, and supercharged features
https://rapideditor.org
ISC License
485 stars 92 forks source link

Busy/Idle events to support code benchmarking #385

Open bhousel opened 2 years ago

bhousel commented 2 years ago

@vanreece has been doing an investigation into code benchmarking and we could really use some more events sprinkled around the various parts of the RapiD code that perform background work (data fetching, etc), so that we're able to run the performance benchmarks when the system is in a quiesced state. (https://github.com/mapbox/mapbox-gl-js/issues/1715 comes to mind).

My plan is to add events like this anywhere that the system is doing background work that might affect performance, or where we might want to show a spinner or something.

then context will also listen to these and keep a count going to expose a main event like:

Will write this in a way that the events will always be matched up, e.g. fire 1 single busy , then later 1 single idle.

bhousel commented 2 years ago

I've added the events to the Esri and FBML services and it's pretty cool - here is with some console logging:

Screen Shot 2021-10-27 at 9 07 27 AM

Also you can bind handlers to context and do this:

Screen Shot 2021-10-27 at 9 10 58 AM

I'm thinking a bit more about how we might want to use these events, and considering:

Just tossing out ideas - don't want to overthink it and we can change it later.

vanreece commented 2 years ago

Awesome. Looking good! I think eventually we may want a more robust system of information that can happen, I could totally imagine some sort of x/y tiles loaded or something eventually happening, but we can always add that later. Thanks Bryan!