Skip to content

Medium sized schema becomes uncomfortably laggy to type in inputs. #3715

@adjenks

Description

@adjenks

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

It's super slow with somewhat large schema with some conditional sections. Typing is extremely laggy.

It appears to run some deep schema merge functions after every keystroke, can I prevent this?

Expected Behavior

Negligible lag.

Steps To Reproduce

Use the following schema to build a form:

var schema = {
  "title": "Demo schema",
  "type": "object",
  "required": [
    "redacted1",
    "redacted2",
    "redacted3",
    "redacted4",
    "redacted5",
    "redacted6"
  ],
  "dependentRequired": {},
  "allOf": [
    {
      "if": {
        "properties": {
          "redacted18": {
            "const": false
          }
        }
      },
      "then": {
        "required": []
      },
      "else": {
        "required": [
          "redacted6"
        ]
      }
    }
  ],
  "properties": {
    "redacted1": {
      "type": "string"
    },
    "redacted2": {
      "type": "string",
      "format": "date"
    },
    "redacted3": {
      "type": "string"
    },
    "redacted4": {
      "type": "string",
      "oneOf": [
        {
          "const": "red1"
        },
        {
          "const": "red2"
        }
      ]
    },
    "total_redacted5": {
      "type": "integer"
    },
    "redacted6a": {
      "type": "string"
    },
    "redacted7": {
      "type": "string"
    },
    "redacted8": {
      "type": "string"
    },
    "redacted9": {
      "type": "string"
    },
    "redacted10": {
      "type": "object",
      "readOnly": true,
      "properties": {
        "red1": {
          "type": "string"
        },
        "red2": {
          "type": "string"
        },
        "red3": {
          "type": "string"
        }
      }
    },
    "redacted11": {
      "type": "integer"
    },
    "redacted12": {
      "type": "string"
    },
    "redacted13": {
      "type": "string",
      "format": "date"
    },
    "redacted14": {
      "type": "array",
      "items": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "title": "Type",
                "oneOf": [
                  {
                    "const": "asdf1"
                  },
                  {
                    "const": "asdf2"
                  },
                  {
                    "const": "asdf3"
                  },
                  {
                    "const": "asdf4"
                  },
                  {
                    "const": "asdf5"
                  },
                  {
                    "const": "asdf6"
                  },
                  {
                    "const": "asdf7"
                  },
                  {
                    "const": "asdf8"
                  },
                  {
                    "const": "asdf9"
                  },
                  {
                    "const": "asdf10"
                  },
                  {
                    "const": "asdf11"
                  },
                  {
                    "const": "asdf12"
                  },
                  {
                    "const": "asdf13"
                  },
                  {
                    "const": "asdf14"
                  },
                  {
                    "const": "asdf15"
                  },
                  {
                    "const": "asdf16"
                  },
                  {
                    "const": "asdf17"
                  },
                  {
                    "const": "asdf18"
                  },
                  {
                    "const": "asdf19"
                  },
                  {
                    "const": "asdf20"
                  },
                  {
                    "const": "asdf21"
                  },
                  {
                    "const": "asdf22"
                  },
                  {
                    "const": "asdf23"
                  },
                  {
                    "const": "asdf24"
                  },
                  {
                    "const": "asdf25"
                  },
                  {
                    "const": "other"
                  }
                ]
              },
              "redacted15": {
                "type": "integer"
              }
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "const": "other"
                }
              }
            },
            "then": {
              "properties": {
                "description": {
                  "type": "string"
                }
              },
              "required": [
                "description"
              ]
            },
            "else": {
              "properties": {}
            }
          }
        ]
      }
    },
    "redacted16": {
      "type": "object",
      "properties": {
        "completed": {
          "type": "boolean"
        },
        "date": {
          "type": "string",
          "format": "date"
        },
        "redacted17": {
          "type": "boolean",
          "oneOf": [
            {
              "const": null,
              "title": "Unknown"
            },
            {
              "const": true,
              "title": "True"
            },
            {
              "const": false,
              "title": "False"
            }
          ]
        }
      }
    },
    "redacted18": {
      "type": "boolean",
      "oneOf": [
        {
          "const": null,
          "title": "Unknown"
        },
        {
          "const": true,
          "title": "True"
        },
        {
          "const": false,
          "title": "False"
        }
      ]
    },
    "redacted6": {
      "type": "string",
      "format": "date"
    },
    "redacted19": {
      "type": "boolean"
    },
    "redacted20": {
      "type": "string",
      "format": "date"
    },
    "redacted21": {
      "type": "boolean"
    },
    "redacted22": {
      "type": "boolean"
    },
    "redacted23": {
      "type": "boolean"
    },
    "redacted24": {
      "type": "integer"
    },
    "redacted25": {
      "type": "integer"
    },
    "redacted26": {
      "type": "string",
      "format": "date"
    },
    "redacted27": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "redacted28": {
            "disabled": true,
            "type": "integer"
          },
          "redacted29": {
            "type": "string",
            "readOnly": true
          },
          "redacted30": {
            "type": "boolean"
          },
          "redacted31": {
            "type": "integer"
          },
          "redacted32": {
            "type": "string"
          },
          "redacted33": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "redacted34": {
                  "type": "string",
                  "readOnly": true,
                  "examples": [
                    "1"
                  ]
                },
                "redacted35": {
                  "type": "string",
                  "readOnly": true,
                  "examples": [
                    "TNT"
                  ]
                },
                "redacted3_code": {
                  "type": "string",
                  "examples": [
                    "820"
                  ]
                },
                "redacted3_en": {
                  "type": "string",
                  "examples": [
                    "ASDFASDFASDF"
                  ]
                },
                "redacted3_fr": {
                  "type": "string",
                  "examples": [
                    "ASDFASDFASDF"
                  ]
                },
                "redacted36": {
                  "type": "string",
                  "examples": [
                    "1"
                  ]
                },
                "redacted37": {
                  "type": "string",
                  "examples": [
                    "14897838"
                  ]
                },
                "redacted38": {
                  "type": "string",
                  "examples": [
                    "9821542"
                  ]
                },
                "redacted39": {
                  "type": "string",
                  "examples": [
                    "4"
                  ]
                },
                "redacted40": {
                  "type": "string",
                  "examples": [
                    "2003"
                  ]
                },
                "redacted41": {
                  "type": "string",
                  "examples": [
                    "AS2"
                  ]
                },
                "redacted42": {
                  "type": "string",
                  "examples": [
                    ""
                  ]
                },
                "redacted43": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "asdf1": {
                        "type": "string",
                        "examples": [
                          "1"
                        ]
                      },
                      "asdf2": {
                        "type": "string",
                        "examples": [
                          "5693"
                        ]
                      },
                      "asdf3": {
                        "type": "string",
                        "examples": [
                          "asdfasdfasdf"
                        ]
                      },
                      "asdf4": {
                        "type": "string",
                        "examples": [
                          "6"
                        ]
                      },
                      "asdf5": {
                        "type": "string",
                        "examples": [
                          "Y"
                        ]
                      },
                      "asdf6": {
                        "type": "string",
                        "examples": [
                          "C"
                        ]
                      },
                      "abc_asdf": {
                        "type": "string",
                        "examples": [
                          "PR"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "version": {
    "title": "Version",
    "type": "string",
    "default": "1.0"
  },
  "$defs": {
    "thingy": {
      "type": "string"
    }
  }
}

Environment

Tested in Chrome and Firefox on Windows

Anything else?

image

The call stack you see in the image occurs on each keystroke and brings my cpu up to 90% each time, there is an average jank/lag of 200ms which makes typing very uncomfortable.

The lag is similar when you paste the schema into the playground, but the playground is slightly more responsive ~150ms instead of 200.

Every yellow bump on the graph is a keystroke and is 90% of my CPU for a brief moment.

The schema is not done yet and will be bigger but I'm afraid it will become completely unusable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions