stride3d/stride · error · NotSupportedException

ActivatedGestures collection was modified but the action…

Error message

ActivatedGestures collection was modified but the action was not supported by the system.

What it means

The ActivatedGestures collection only supports Add and Remove operations. Replace and Reset changes throw NotSupportedException because the gesture recognition pipeline cannot swap or clear gesture configurations atomically, and Move is ignored.

Solutions

  1. Remove gesture configs individually with ActivatedGestures.Remove(g) instead of Clear().
  2. Add new configs one by one with Add after removing the old ones.
  3. Replace the whole gesture set only before the InputManager starts processing, or stop recognition first.

Example fix

// before
input.ActivatedGestures.Clear();
// after
foreach (var g in input.ActivatedGestures.ToList())
    input.ActivatedGestures.Remove(g);
Defensive patterns

Strategy: validation

Validate before calling

// never call Clear(); remove items one by one
foreach (var g in input.ActivatedGestures.ToList()) input.ActivatedGestures.Remove(g);

Try / catch

try { gestures.Clear(); }
catch (NotSupportedException ex) when (ex.Message.Contains("ActivatedGestures"))
{ foreach (var g in gestures.ToList()) gestures.Remove(g); }

Prevention

When it happens

Trigger: Calling ActivatedGestures.Clear() (Reset), assigning a new gesture at an index (Replace), or bulk-replacing the collection contents after the manager is running.

Common situations: Trying to reset gesture settings between levels/screens by clearing the collection; swapping configurations in place; data-binding replacing the whole collection.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/621359481a23a522. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Input/InputManager.cs:748

            foreach (var source in Sources)
            {
                source.Dispose();
            }
        }

        private void GesturesOnCollectionChanged(object sender, TrackingCollectionChangedEventArgs trackingCollectionChangedEventArgs)
        {
            switch (trackingCollectionChangedEventArgs.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    StartGestureRecognition((GestureConfig)trackingCollectionChangedEventArgs.Item);
                    break;
                case NotifyCollectionChangedAction.Remove:
                    StopGestureRecognition((GestureConfig)trackingCollectionChangedEventArgs.Item);
                    break;
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Reset:
                    throw new NotSupportedException("ActivatedGestures collection was modified but the action was not supported by the system.");
                case NotifyCollectionChangedAction.Move:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }

        private void StartGestureRecognition(GestureConfig config)
        {
            float aspectRatio = Pointer?.SurfaceAspectRatio ?? 1.0f; 
            gestureConfigToRecognizer.Add(config, config.CreateRecognizer(aspectRatio));
        }

        private void StopGestureRecognition(GestureConfig config)
        {
            gestureConfigToRecognizer.Remove(config);
        }

View on GitHub (pinned to 96fad776d2)