Skip to content

Crash when typing in a lexical view which has decorators: Terminating app due to uncaught exception 'NSInternalInconsistencyException' #34

@MilesV64

Description

@MilesV64

After inserting a custom decorator into the document and then typing more, I get the following crash:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[Lexical.LayoutManager _fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *** attempted layout while textStorage is editing. It is not valid to cause the layoutManager to do layout while the textStorage is editing (ie the textStorage has been sent a beginEditing message without a matching endEditing.)'

The crash is on line 544 of Editor:
frontend?.layoutManager.invalidateLayout(forCharacterRange: rangeCacheItem.range, actualCharacterRange: nil)

This makes me very nervous to use the library in production, any advice on how to avoid this crash?

Here's the JSON of my lexical right before the crash (I was printing after every edit):

{
  "root": {
    "direction": null,
    "format": "",
    "indent": 0,
    "type": "root",
    "children": [
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "Test  niceee ",
            "version": 1,
            "type": "text"
          },
          {
            "type": "timestamp",
            "version": 1,
            "timestamp": 34.43114
          },
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": " ",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "New line fdsa ",
            "version": 1,
            "type": "text"
          },
          {
            "type": "timestamp",
            "version": 1,
            "timestamp": 34.43114
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "E",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "Weeeeee",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "Weeee",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "Da",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "Test ",
            "version": 1,
            "type": "text"
          },
          {
            "type": "timestamp",
            "version": 1,
            "timestamp": 34.43114
          },
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": " ",
            "version": 1,
            "type": "text"
          },
          {
            "format": 1,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "tello",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "F",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      },
      {
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "children": [
          {
            "format": 0,
            "detail": 0,
            "style": "",
            "mode": "normal",
            "text": "F",
            "version": 1,
            "type": "text"
          }
        ],
        "version": 1
      }
    ],
    "version": 1
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions