AppFlowy-IO / AppFlowy-IO/appflowy-editor

Editing a table then defocusing freezes the app (infinite row-height relayout loop)

Offen
#1,213 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
684
Forks
329
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Description

On mobile, PWA app - editing a table cell and then defocusing it (tapping/clicking outside the cell) reliably freezes the app. The UI isolate is pinned at 100% and the app stops responding (ANR on Android). No exception is thrown, so it surfaces as a hang rather than a crash nothing reaches `FlutterError.onError`, `PlatformDispatcher.onError`, or any `try/catch`.

### Steps to reproduce

1. Insert a table into a document on Android + Chrome
2. Focus a cell and type some text.
3. Tap/click outside the cell to defocus it.
4. The editor enters an unbounded relayout loop and stops responding (eventual "Oh, snap")

### Expected behavior

The table settles after the cell is defocused.

### Actual behavior

Continuous relayout; the app freezes.

### Root cause

`TableCol._buildCells` schedules `updateRowHeightCallback` in a post-frame callback on **every build**. That callback calls `TableNode.updateRowHeight`, which writes a new cell/cols height whenever the stored height attribute differs from the measured `children.first.rect.height` using an **exact `!=` comparison**:

```dart
if (_cells[0][row].attributes[TableCellBlockKeys.height] != maxHeight &&
!maxHeight.isNaN) { ... }
...
if (node.attributes[TableBlockKeys.colsHeight] != colsHeight &&
!colsHeight.isNaN) { ... }
```

Measured heights jitter by sub-pixel amounts between frames (device-pixel rounding, and a focus/selection-dependent measurement on mobile). Exact inequality treats that jitter as a real change, so a height transaction is emitted every frame → `editorState.apply(transaction)` → rebuild → re-measure → loop forever. There is no convergence tolerance.

### Environment

- `appflowy_editor`: 6.2.0
- Flutter: 3.41.2 stable
- Platform: Android 16 / Chrome

### Proposed fix

Compare the stored and measured heights with a small tolerance (≥ 1 logical pixel) so `updateRowHeight` stops emitting transactions once the height is within a pixel of the measurement. Imperceptible visually, safely above the jitter, and guarantees the loop terminates. A PR with a regression test follows.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.