Describe the bug
When interacting with long running (25+ days) application on 32-bit Linux I get OverflowException with following stacktrace:
System.Private.CoreLib
at System.OverflowException..ctor(String message)
at System.TimeSpan.IntervalFromDoubleTicks(Double ticks)
at Avalonia.Input.GestureRecognizers.ScrollGestureRecognizer.PointerPressed(PointerPressedEventArgs e)
at Avalonia.Input.GestureRecognizers.GestureRecognizerCollection.HandlePointerPressed(PointerPressedEventArgs e)
at Avalonia.Input.InputElement.<>c.<.cctor>b__32_13(InputElement x, PointerPressedEventArgs e)
at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value)
at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e)
at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e)
at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
at Avalonia.Input.TouchDevice.ProcessRawEvent(RawInputEventArgs ev)
at Avalonia.Controls.TopLevel.<>c.<HandleInput>b__150_0(Object state)
at Avalonia.Threading.Dispatcher.Send(SendOrPostCallback action, Object arg, Nullable`1 priority)
at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e)
at Avalonia.ManualRawEventGrouperDispatchQueue.DispatchNext()
at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
at Appl.Program.Main(String[] args)
To Reproduce
Let application containing ScrollGestureRecognizer run for 25 days and interact with it. Or pass events containing large enough timestamps to the ScrollGestureRecognizer.
Expected behavior
Not crash
Avalonia version
11.2.x, but looking at the code it should affect master also
OS
Linux
Additional context
Looking at it closer, it's two issues in one:
- Input event timestamps overflow after ~25 days, and negative values are converted to large ulong values
|
Timestamp = (ulong)ev->time.ToInt64(); |
- Timestamps are converted to TimeSpans, which have limited range that doesn't allow these large overflowed UInt64 values
|
_velocityTracker?.AddPosition(TimeSpan.FromMilliseconds(e.Timestamp), default); |
Describe the bug
When interacting with long running (25+ days) application on 32-bit Linux I get OverflowException with following stacktrace:
To Reproduce
Let application containing ScrollGestureRecognizer run for 25 days and interact with it. Or pass events containing large enough timestamps to the ScrollGestureRecognizer.
Expected behavior
Not crash
Avalonia version
11.2.x, but looking at the code it should affect master also
OS
Linux
Additional context
Looking at it closer, it's two issues in one:
Avalonia/src/Avalonia.X11/XI2Manager.cs
Line 560 in f13bfe6
Avalonia/src/Avalonia.Base/Input/GestureRecognizers/ScrollGestureRecognizer.cs
Line 115 in f13bfe6