Most (but not all) of these errors were found to correlate to pages with either high image counts (> 1000) or high heading counts (> 1000). Therefore, if we want these pages to not timeout anymore, we could try skipping the MobileFormatter altogether under these scenarios.
- Each of the cases I looked at had extremely high total element counts (> 50,000 total elements on the page). The suggested fix may remedy the majority of the timeout errors, however client side performance on mobile devices could still be pretty abysmal (e.g. slow/unuseable repaints, scroll freezing, etc). Therefore, it's probably not wise to spend a lot of time implementing this fix as it's really just a bandaid for the majority of cases.
- Using preg_match_all to get the counts might work well here
- When a page has > 1000 images or > 1000 headings, don't run the MobileFormatter