stride3d/stride · error · Exception

Internal error: Can not activate edit text, another edit…

Error message

Internal error: Can not activate edit text, another edit text is already active

What it means

This error is thrown by Stride.UI's Android EditText backing store when a second native edit text is about to be activated while one is already active. The class keeps a single static/active native EditText popup per process, so only one control may hold it at a time. It signals an internal state-machine violation in UI focus management rather than a caller mistake.

Solutions

  1. Ensure the currently active EditText is deactivated (focus lost / selection cleared) before activating another one
  2. Only programmatically activate an EditText when IsSelectionActive is false
  3. Check for leaked activation: if the first EditText was removed from the tree while active, deactivate or dispose it first
  4. Reproduce with a minimal two-EditText focus script and report as a Stride bug if the framework leaves activeEditText set

Example fix

// before
editTextA.ActivateFocus();
editTextB.ActivateFocus(); // throws: A still active
// after
editTextA.DeactivateFocus(); // or move focus away first
editTextB.ActivateFocus();
Defensive patterns

Strategy: try-catch

Validate before calling

if (activeEditText != null && activeEditText != myEditText)
    activeEditText.DeactivateFocus(); // release native popup first

Type guard

bool CanActivate(EditText e) => e != null && !e.IsSelectionActive;

Try / catch

try
{
    editText.ActivateFocus();
}
catch (Exception ex) when (ex.Message.Contains("another edit text is already active"))
{
    // deactivate the other EditText and retry once, or log a focus-management bug
}

Prevention

When it happens

Trigger: Calling ActivateEditTextImpl (directly or via focus/selection APIs such as IsSelectionActive touching selection activation) while activeEditText is already set to another control; activating two EditTexts without deactivating the first; a prior EditText failing to release the native popup during deactivation.

Common situations: Programmatically focusing a second text input while a first still has focus on Android; UI layouts where focus transitions skip the deactivate step; headless or automated test harnesses where native popup teardown behaves differently.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.UI/Controls/EditText.Android.cs:240

                return;

            editText.Post(editTextSetMaxLinesAction);
        }

        private void OnMinLinesChangedImpl()
        {
            if (editText == null)
                return;

            editText.Post(editTextSetMinLinesAction);
        }

        private void ActivateEditTextImpl(InputManager inputManager)
        {
            lock (syncRoot)
            {
                if (activeEditText is not null)
                    throw new Exception("Internal error: Can not activate edit text, another edit text is already active");

                EnsureStaticEditText();
                if (staticEditText is null)
                    return;  // headless test environment — no native popup means no activation

                activeEditText = this;

                // Select all text on initial focus.
                // TODO: Maybe make it configurable on how caret/selection should default on activation?
                SelectAll();
                // Note that we do not assign 'staticEditText' to 'editText' until the Post action
                // is actually invoked to ensure the control is fully ready
                staticEditText.Post(editTextSetActivatedStateAction);

                GetGameContext()?.ShowEditTextPopup();
            }
        }

View on GitHub (pinned to 96fad776d2)