-
Notifications
You must be signed in to change notification settings - Fork 17
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
AG-13363 Long-Tap iOS Safari #3442
base: latest
Are you sure you want to change the base?
Conversation
This stops iOS Safari from trying to select text when long-tapping the canvas.
d7afc0f
to
a02e98e
Compare
} | ||
}; | ||
const touchend = (endEvent: TouchEvent) => { | ||
longTapInterrupted = true; |
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.
In the cases where longTapInterrupted
is set to true
, could you cancel the setTimeout()
via clearTimeout()
so that we don't have dangling JS variable contexts hanging around?
It would also be good if we could clear these up on chart.destroy()
too, otherwise the callback could happen after chart destruction, with inevitable errors - also references in the callback context can prevent garbage collection?
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.
In the cases where
longTapInterrupted
is set totrue
, could you cancel thesetTimeout()
viaclearTimeout()
so that we don't have dangling JS variable contexts hanging around?
Can you clarify how we would end up with a dangling reference? I don't mind using clearTimeout()
, but I cannot see how that improves memory safety. Without a clearTimeout()
, the setTimeout()
will eventually call then remove the function, which would in turn make its variable context eligible for garbage collection.
It would also be good if we could clear these up on
chart.destroy()
too, otherwise the callback could happen after chart destruction, with inevitable errors
The callbacks will not cause errors because we always remove the listeners on chart.destroy()
(see WidgetListenerInternal.destroy()
). So these callbacks will, at worst, loop through an undefined or empty array of listeners.
Calling chart.destroy()
whilst a finger is being dragged on that chart can indeed delay garbage collection until after the finger is lifted. Removing the listeners on chart.destroy()
isn't necessary, but it would stop this delay. However, the challenge is that these are global callbacks shared amongst all chart instances, we must be cautious to ensure that destroying one chart doesn't interrupt another chart that's currently being dragged.
We could perhaps refactor the startMouseDrag
and startOneFingerTouch
to be temporary member objects of WidgetListenerInternal
to manage the memory better. But the way I see it there's very little gain in doing that: there's only one mouse & touch device in the window
and therefore there's only ever one drag motion in progress. So we can safely manage the memory regardless of whether or not the chart gets destroyed.
also references in the callback context can prevent garbage collection?
Are you referring to that.globalTouchDragCallbacks
? If yes, that variable is used correctly AFAIK. It sets to undefined
either in the touchend
handler (called on 'touchstart', 'touchend' or 'touchcancel') or in the WidgetListenerInternal.destroy()
method (called by chart.destroy()
).
https://ag-grid.atlassian.net/browse/AG-13363
Depends on:
zoom.dragAction: 'drag'
#3439