Scenario

Backspace with Samsung Keyboard causes editor crash

On Android with Samsung Keyboard, holding the backspace key to delete text causes the contenteditable editor to crash completely. JavaScript execution stops and page becomes unresponsive.

mobile
Scenario ID
scenario-samsung-backspace-crash

Details

On Android with Samsung Keyboard, holding the backspace key to delete text causes the contenteditable editor to crash completely.

Problem Description

This issue occurs specifically when:

  1. User is on Android device
  2. User is using Samsung Keyboard (system default or Samsung input app)
  3. User has typed text in a contenteditable editor
  4. User holds the backspace key to delete multiple characters

Expected Behavior

  • Characters should be deleted one by one as backspace is held
  • Editor should continue functioning normally
  • No crash should occur

Actual Behavior (Samsung Keyboard Bug)

  • Editor crashes: Contenteditable editor completely crashes
  • JavaScript execution stops: All script execution halts
  • Page unresponsive: Browser becomes unresponsive
  • Requires page reload: User must reload the page to continue

Affected Browsers

  • Chrome for Android (with Samsung Keyboard) - Issue confirmed
  • Samsung Internet Browser - Likely affected (Chromium-based)
  • Firefox for Android - May not be affected
  • Other keyboards - Gboard, SwiftKey, etc. do NOT exhibit this crash

Affected Devices

  • Samsung Galaxy devices (S9, S10, Note series, etc.)
  • Other Android devices with Samsung Keyboard installed

Root Cause

Samsung Keyboard’s backspace handling appears to have a race condition or memory corruption when:

  1. Multiple backspace events are fired rapidly (holding key)
  2. The editor’s DOM manipulation doesn’t keep up
  3. Internal state becomes inconsistent
  4. JavaScript engine crashes due to invalid state

Workarounds

  1. Rate-limit backspace events:

    let lastBackspaceTime = 0;
    const BACKSPACE_DELAY = 50; // 50ms between events
    
    editor.addEventListener('keydown', (e) => {
      if (e.key === 'Backspace') {
        const now = Date.now();
        if (now - lastBackspaceTime < BACKSPACE_DELAY) {
          e.preventDefault();
          console.warn('Backspace rate limited');
          return;
        }
        lastBackspaceTime = now;
      }
    });
  2. Use try-catch around DOM operations:

    editor.addEventListener('input', (e) => {
      try {
        // Handle input
      } catch (error) {
        console.error('Input error:', error);
        // Recover gracefully
      }
    });
  3. Debouce backspace handling:

    let backspaceTimeout = null;
    
    editor.addEventListener('keydown', (e) => {
      if (e.key === 'Backspace') {
        clearTimeout(backspaceTimeout);
        backspaceTimeout = setTimeout(() => {
          // Handle backspace with delay
          performBackspace();
        }, 10); // 10ms debounce
      }
    });
  4. Provide user education:

    • Add UI hint that Samsung Keyboard may cause issues
    • Recommend using alternative keyboards (Gboard, SwiftKey)
    • Warn about holding backspace key
  5. Use MutationObserver for DOM changes:

    const observer = new MutationObserver((mutations) => {
      try {
        // Validate DOM changes
      } catch (error) {
        console.error('Mutation error:', error);
      }
    });
    
    observer.observe(editor, {
      childList: true,
      subtree: true,
      characterData: true
    });

References

Scenario flow

Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.

React Flow mini map

Variants

Each row is a concrete case for this scenario, with a dedicated document and playground.

Case OS Device Browser Keyboard Status
ce-0291-samsung-backspace-crash-en Android 10-14 Mobile (Samsung Galaxy S9, Note series, etc.) Any Chrome for Android 120+ English (QWERTY) draft

Cases

Open a case to see the detailed description and its dedicated playground.

Related Scenarios

Other scenarios that share similar tags or category.

Tags: android, samsung-keyboard

Samsung Keyboard Text Prediction Issues in contenteditable

Samsung keyboard's text prediction feature causes various input event handling issues in contenteditable elements on Android Chrome, including insertCompositionText events, missing getTargetRanges(), selection mismatches, and combined event.data when typing adjacent to links or formatted elements.

1 case
Tags: android

Input Events Fire on Focus/Blur in Chrome Android

In Chrome on Android, input events may fire when a contenteditable element gains or loses focus, even without content changes. This behavior can lead to unintended side effects in applications relying on input events for content modification detection.

1 case
Tags: android

enterkeyhint attribute does not work on contenteditable

The enterkeyhint attribute, which controls the label on the Enter key on mobile keyboards, does not work on contenteditable elements. The Enter key label remains the default regardless of the attribute value.

1 case

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.