-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix picking perf when dragging #775
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
Conversation
src/utils/events/event-manager.js
Outdated
* Process the event deregistration for a single event + handler. | ||
*/ | ||
_removeEventHandler(event, handler) { | ||
let success = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: call this eventHandlerRemoved
to be a bit more explicit about what succeeded
}; | ||
|
||
// Calculate center relative to the root element | ||
// TODO/xiaoji - avoid using getBoundingClientRect for perf? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you decide this is not a perf concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find it prominent during profiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be conclusive. It reportedly depends on the surrounding DOM, how deep we are in the DOM tree, styling etc.
Whether it is worth the trouble to avoid I don't know...
if (alias) { | ||
// fire all events aliased to srcEvent.type | ||
const emitEvent = Object.assign({}, event, {type: alias}); | ||
const emitEvent = Object.assign({}, event, {isDown: true, type: alias}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're always setting isDown: true
here, should the third Object.assign()
param be the second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're overriding event.type
.
Worth noting that this PR fixes the more obvious perf problem during dragging (perf slows down the screen update while dragging), but not the more subtle perf problem that happens when running picking on hover (mousemove without mousedown). The latter is for a future PR. |
}; | ||
|
||
// Calculate center relative to the root element | ||
// TODO/xiaoji - avoid using getBoundingClientRect for perf? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be conclusive. It reportedly depends on the surrounding DOM, how deep we are in the DOM tree, styling etc.
Whether it is worth the trouble to avoid I don't know...
src/utils/events/event-manager.js
Outdated
import WheelInput from './wheel-input'; | ||
import MoveInput from './move-input'; | ||
import {isBrowser} from '../globals'; | ||
import {isBrowser} from '../../lib/utils/globals'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these utils should be moved up a level if they are no longer used only inside lib.
src/lib/layer-manager.js
Outdated
*/ | ||
_onPointerMove(event) { | ||
if (event.isDown) { | ||
// Is dragging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a little more to the comment i.e. why does dragging mean that we don't need move events?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment means we should not fire pointermove event when mouse is down because pointermove leads to pickLayer getting called. Yes, we probably want to explain a bit more in the comments, or considering put a link to this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, more specifically _onPointerMove
feeds into our hover handlers (onHover
and onLayerHover
), and dragging is not supported by the framework itself, it's the app's responsibility. But yeah, fleshing out the comment will help future detective work.
@@ -1,15 +0,0 @@ | |||
// Purpose: include this in your module to avoids adding dependencies on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this deleted?
- Update EventManager - Add `isDown` property to pointer events - Prevent picking when dragging
isDown
property to pointer events