584380ba8b
This PR buffs input events. ## The story so far In the olde days, we throttled events from the canvas events hook so that a pointer event would only be sent every 1/60th of a second. This was fine but made drawing on the iPad / 120FPS displays a little sad. Then we removed this throttle. It seemed fine! Drawing at 120FPS was great. We improved some rendering speeds and tightened some loops so that the engine could keep up with 2x the number of points in a line. Then we started noticing that iPads and other screens could start choking on events as it received new inputs and tried to process and render inputs while still recovering from a previous dropped frame. Even worse, on iPad the work of rendering at 120FPS was causing the browser to throttle the app after some sustained drawing. Yikes! ### Batching I did an experimental PR (#3180) to bring back batching but do it in the editor instead. What we would do is: rather than immediately processing an event when we get it, we would instead put the event into a buffer. On the next 60FPS tick, we would flush the buffer and process all of the events. We'd have them all in the same transaction so that the app would only render once. ### Render batching? We then tried batching the renders, so that the app would only ever render once per (next) frame. This added a bunch of complexity around events that needed to happen synchronously, such as writing text in a text field. Some inputs could "lag" in a way familiar to anyone who's tried to update an input's state asynchronously. So we backed out of this. ### Coalescing? Another idea from @ds300 was to "coalesce" the events. This would be useful because, while some interactions like drawing would require the in-between frames in order to avoid data loss, most interactions (like resizing) didn't actually need the in-between frames, they could just use the last input of a given type. Coalescing turned out to be trickier than we thought, though. Often a state node required information from elsewhere in the app when processing an event (such as camera position or page point, which is derived from the camera position), and so the coalesced events would need to also include this information or else the handlers wouldn't work the way they should when processing the "final" event during a tick. So we backed out of the coalescing strategy for now. Here's the [PR that removes]( |
||
---|---|---|
.. | ||
export-snapshots.spec.ts-snapshots | ||
fixtures | ||
test-canvas-events.spec.ts-snapshots | ||
export-snapshots.spec.ts | ||
test-actions-menu.spec.ts | ||
test-api.spec.ts | ||
test-camera.spec.ts | ||
test-canvas-events.spec.ts | ||
test-clipboard.spec.ts | ||
test-context-menu.spec.ts | ||
test-focus.spec.ts | ||
test-help-menu.spec.ts | ||
test-kbds.spec.ts | ||
test-main-menu.spec.ts | ||
test-navigation-panel.spec.ts | ||
test-page-menu.spec.ts | ||
test-routes.spec.ts | ||
test-shapes.spec.ts | ||
test-smoke.spec.ts | ||
test-style-panel.spec.ts | ||
test-text.spec.ts | ||
test-toolbar.spec.ts |