H5P.MathDisplay makes larger H5P content painfully slow

Description

Background

H5P.MathDisplay calls waitForMathJaxDone() ~10 times per second, at least, which in turn triggers resize of the window leading to numerous recalculations throughout the entire H5P content. The larger the content the slower it gets.
This function also sometimes uses setInterval(), which does not wait for the last processing to finish before firing off a new one. Essentially creating an infinite loop starting the next "resize" before the previous is done.
This makes larger Interactive Videos skip frames evens on modern computers.

Acceptance Criteria

1. Do not trigger resize on window/content unless it has changed size.
2. Do not use a timer to check for or assume changes N times per second. Find a scalable approach.
3. Do not use setInterval() when you are not 100% confident that the callback will finish before triggering the next.

Environment

None

Acceptance Criteria

None

Assignee

Frode Petterson

Reporter

Frode Petterson

Labels

Funding

None

Code reviewer

None

Released

None

Time tracking

3h

Fix versions

Sprint

Priority

High
Configure