mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-11 17:35:05 +00:00
## About The Pull Request Doesn't quite fix but helps mitigate #71697 - The issue report is still valid, just less so. Marked.js is just... Slow when used in BYOND's web browsing environment. New markdown elements **and HTML tags** add significant fractions of a millisecond to parsing time on my local. However, I suspect I messed up with using the custom extensions and every parsing pass it may have be appending a new extension to the extension list. I'm not sure why this never manifested in my 6 minutes of testing gif from the original PR, mind you. I checked out that commit and local and everything worked the same as I remember. Perhaps a change or version bump in the interim modified the behaviour. That aside, on current master it's MASSIVELY obvious something is fucked. Spamming 1000 characters of ``` # Slow ## Slower ### Slowest ``` then saving it, then puting **another** 1000 characters of the same thing for 2000 previewed characters total gave the following performance metrics:  The marked.js parse time was about 150-180ms for the saved text and 220+ms for the input box text. Moreso, if you leave the paper open for for a few minutes...  Yeah. That's 500+ms per parse (with 2 per render - one from the paper's saved text and one from the input box) and the game will basically crash. Similar results using this template provided to me for testing purposes: ``` <center><b>Department Psychological Evaluation Survey</b></center> <center><i>Test Log 230126-01</i></center> <b>Question 1</b> What department do you work in? [_____________________________________] <b>Question 2</b> Which department are you least likely to recommend to a friend that they should work in? <i>Please only choose one</i> * Command [__] * Security [__] * Service [__] * Cargo [__] * Medical [__] * Science [__] * Engineering [__] <b>Question 3</b> Which department are you most likely to recommend to a friend that they should work in? <i>Please only choose one</i> * Command [__] * Security [__] * Service [__] * Cargo [__] * Medical [__] * Science [__] * Engineering [__] <b>Question 4</b> What is your favorite animal? [_____________________________________] --- Please sign here to confirm you are completing this survey voluntarily: [_____________________________________] <i>All Nanotrasen brand pens have an automatic signature system. Please write % s to automatically sign it.</i> ``` On first input + save, render time is normal but you can see it clearly rising each second...   You get the idea. Fixing the problem by using the proper markdown method for accomplishing the same thing: Markdown # Slow # Slower # Slowest test:  HoPaperwork Form  And these numbers don't increase over time. So I think I nailed an interim fix. Ultimately, marked.js in tgui/BYOND just seems slow as molasses. But it can at least be **usable** for now and this should majorly mitigate or even eliminate problems players have been having with paper (depending on how loaded it is with HTML and markdown tags). All the features we had before seem to still work after I feex. So hopefully good for now?  ## Beeg edit I decided I'd go a step further and implement some basic caching logic.  This means that you don't pay a parsing cost from already saved text while writing new text, allowing complex forms to be created in multiple saved or one big copy-paste. This means that reading paper and filling in input boxes in paper is free after the first parse, using the cache afterwards. This is a workaround for the fact a parse can take longer than we'd like for complicated paper forms. ## Why It's Good For The Game Paper good. ## Changelog 🆑 fix: Papercode has been significantly improved and trivially filled paper forms should no longer lag or crash players' game clients. /🆑