u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
187 stars 30 forks source link

Web Build Slowed by Log Output #54

Closed SirNate0 closed 1 year ago

SirNate0 commented 1 year ago

I recently traced a performance issue in the web build of my game down to doing logging during a character's attack. My build used the default shell (constructed by the UrhoCommon.cmake module from the default emscripten shell.html), which renders the console output both to the java script console and to an element on the page, which it then scrolls to the end of. This triggers a reflow of the text to get the element height, and since the log gets longer and longer, this takes a longer and longer amount of time, dropping frame rate drastically (down to ~3FPS).

The Urho3D shell.html file does not have this problem, as it just prints to the JS console (here).

I think the best solution to this issue is to use the Urho shell file by default in user projects, and not one based on the emscripten default. As a bonus, this shell looks much prettier and is more suited for games (full window, with simply a button to make it full screen) than the default shell (which is also meant to support console apps and such).