Unplanned
Last Updated: 08 Jun 2026 11:59 by ADMIN
Hemen
Created on: 08 Jun 2026 07:55
Category: UI for .NET MAUI
Type: Bug Report
0
RadSignaturePad: Unhandled "Sequence contains no elements" in SingleTouchSegmentProvider.OnTouch when touch events arrive after segment collection is cleared

Component: SignaturePad

Version: Telerik UI for .NET MAUI 12.0.0 .NET: .NET 10 / .NET MAUI

Platform: Reproduced on iOS (iPad, iPhone) and Android (Samsung). Cross-platform — bug is in the shared SingleTouchSegmentProvider, not in a platform-specific touch handler.


Description

RadSignaturePad crashes the app with an unhandled InvalidOperationException: "Sequence contains no elements" thrown from the touch event pipeline. Because the exception originates inside the native→managed touch callback, it cannot be caught by user code and propagates to AppDomain.CurrentDomain.UnhandledException, terminating the app.

The root cause is a .Last() call on an empty segment collection inside SingleTouchSegmentProvider.OnTouch. The crash occurs in both TouchesMoved and TouchesEnded paths, indicating a missing guard at the central OnTouch entry point — not in a specific touch phase.

Reliable repro

  1. Place a RadSignaturePad and a separate button that invokes signaturePad.ClearCommand.
  2. Begin drawing a stroke on the SignaturePad (finger down, do not lift).
  3. With another finger (or hand), tap the Clear button while the stroke is still active.
  4. Continue moving the drawing finger.

TouchesMoved fires after ClearCommand has emptied the internal segment collection. SingleTouchSegmentProvider.OnTouch calls .Last() on the empty collection and throws.

Reproduced on:

  • iPad (iPad12,1), iOS 26.4.28 — 100 % reproducible
  • iPhone, iOS — 100 % reproducible
  • Samsung phone, Android — 100 % reproducible

The same crash also occurs on TouchesEnded in less deterministic scenarios — palm rejection, multi-touch cancellation, Apple Pencil hover-to-touch transitions, or a touch that begins outside the view and ends inside it. All of these can deliver a touch event without a corresponding active segment. We've observed this variant in production on iPad but could not reliably reproduce it in isolation.

Stack trace (TouchesMoved variant — reproducible)

System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[Segment](IEnumerable`1 source)
   at Telerik.Maui.Controls.SignaturePad.SingleTouchSegmentProvider.OnTouch(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignaturePad.SegmentProvider.TouchRecognizer_Touch(Object sender, InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignatureView.OnTouch(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignatureViewHandler.<ConnectHandler>b__3_0(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.FireEvent(InteractionAction actionType, UITouch touch)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.TouchesMoved(NSSet touches, UIEvent evt)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.__Registrar_Callbacks__.callback_1171_..._TouchesMoved(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle)

Stack trace (TouchesEnded variant — same root cause, observed in production)

System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[Segment](IEnumerable`1 source)
   at Telerik.Maui.Controls.SignaturePad.SingleTouchSegmentProvider.OnTouch(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignaturePad.SegmentProvider.TouchRecognizer_Touch(Object sender, InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignatureView.OnTouch(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignatureViewHandler.<ConnectHandler>b__3_0(InteractionAdapterEventArgs args)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.FireEvent(InteractionAction actionType, UITouch touch)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.TouchesEnded(NSSet touches, UIEvent evt)
   at Telerik.Maui.Controls.SignaturePad.SignatureViewTouchHandler.__Registrar_Callbacks__.callback_1162_..._TouchesEnded(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle)

Minimal XAML


<telerik:RadSignaturePad
    x:Name="signaturePad"
    StrokeThickness="5"
    StrokeColor="Black"
    BackgroundColor="White" />
<Button Text="Clear" Clicked="OnClearClicked" />

void OnClearClicked(object s, EventArgs e) { if (signaturePad.ClearCommand.CanExecute(null)) signaturePad.ClearCommand.Execute(null);

}

No custom touch handlers, no SegmentProvider override, no gestures attached.

Expected behaviour

SingleTouchSegmentProvider.OnTouch should guard against an empty segment collection (e.g. .LastOrDefault() + null check, or an early return when no active segment exists). Touch events arriving after a Clear — or without a preceding TouchesBegan — should be ignored, not throw.

Workaround applied on our side

We disable the Clear button while a stroke is active (toggled in StrokeStarted / StrokeCompleted). This closes the deterministic repro but does not cover the non-deterministic TouchesEnded cases (palm rejection etc.), which still crash. A fix in SingleTouchSegmentProvider.OnTouch is required.

Impact

App crash on a customer-visible workflow (digital signature capture on service tickets). Affects production users on iPads, iPhones, and Android devices.

Asks

  1. Please confirm and provide a fix version / ETA.
  2. Until fixed, is there a supported extension point to override SignatureViewTouchHandler or SegmentProvider so we can guard OnTouch from user code?

0 comments