switchbrew / nx-hbloader

Host process for loading Switch homebrew NROs
ISC License
338 stars 72 forks source link

Use 16 MB less heap so swkbd will work even as applet #14

Closed rsn8887 closed 5 years ago

rsn8887 commented 5 years ago

It would be great if hbloader could reduce its heap allocation (svcSetHeapSize) by 0x1000000. That's just 16 MB less. Then swkbd would work even in applets.

At least I think so.

fincs commented 5 years ago

Memory reserved to applets is already pretty scarce. Some homebrew apps are going to be unhappy if we reduce heap even more. People are encouraged to move to Application target titles for hbl, and leave the album applet as a last resource legacy title to use as the homebrew entrypoint.

rsn8887 commented 5 years ago

I was wrong, after some more testing, the swkbd seems to need around 0x8000000 so 128 MB.... that is quite a lot. All preliminary since I am just using svcSetHeapSize and don't consider side effects.

fincs commented 5 years ago

Do not use svcSetHeapSize (and thus corrupt the environment), and instead run your homebrew on top of an Application target title as you are intended to.

ckurtz22 commented 5 years ago

Do not use svcSetHeapSize (and thus corrupt the environment), and instead run your homebrew on top of an Application target title as you are intended to.

What about when homebrew has to be ran in the Album? Such as EdiZon, for memory stuff

fincs commented 5 years ago

Album applet homebrew (which is memory limited by the system, not by libnx) is a last resort option and shouldn't be used in normal circumstances. Please use Atmosphère's first-class HBL support to run homebrew under an actual application target title.

ckurtz22 commented 5 years ago

Well that's the point. There are certain applications that have to use Album, because they need to be ran alongside a game, like with EdiZon's memory searching utility. If your recommendation is to always use homebrew via Atmosphere's title override feature and not Album regardless, then I don't see what the issue is with allowing homebrew that has to use Album to use the swkbd. Like you said, homebrew that needs to utilize more memory should always use title takeover on standard applications, so amount of memory allocated to homebrew within Album should not be an issue. (maybe an older, legacy issue, but no longer thanks to application title takeover)

fincs commented 5 years ago

It is simply unworkable to allow swkbd usage under the Album applet for the reasons explained before. It is difficult to predict how much memory swkbd needs to have available to itself, and reducing the already limited amount of memory exposed to homebrew even further will almost certainly break complex homebrew such as EdiZon.

ckurtz22 commented 5 years ago

EdiZon already does the svcSetHeapSize "fix" for utilizing swkbd since there is not sufficient functionality for it through HBL.

fincs commented 5 years ago

That is not a fix. That is a bodge, and it is a violation of the homebrew ABI. Applications should not call svcSetHeapSize at all, only nx-hbloader is allowed to do so.