Merge request freezes on switching between inline and side-by-side view

Summary

When you have a merge request with a couple thousand lines of changed code and you switch between "Inline" and "Side-by-side" view the browser becomes completely unresponsive. Depending on the number of changes the browser may start responding again after a while or completely hang forever.

Steps to reproduce

  1. Create a merge request with a couple thousand lines of changed code (the behaviour is noticeable with much less changed code but it makes it more obvious when the change is larger)
  2. Change the display settings from "Inline" to "Side-by-side"
  3. Notice the browser window becomes completely unresponsive

Example Project

See this merge request for a demonstration of the issue: bzuurendonk/merge-request-issue-demo-project!1

What is the current bug behavior?

The browser becomes completely unresponsive.

What is the expected correct behavior?

No unresponsiveness of the browser.

Relevant logs and/or screenshots

N/A

Output of checks

This bug happens on GitLab.com