LumaTeam / Luma3DS

Nintendo 3DS "Custom Firmware"
GNU General Public License v3.0
5.33k stars 562 forks source link

2DS SleepMode Bug #1222

Closed Bfbdjdi closed 5 years ago

Bfbdjdi commented 5 years ago

System model: Old 2DS [e.g. 2DS, New 3DS, Old 3DS]

SysNAND version (+emu/redNAND version if applicable): 11.9.0-xxU ("x" I don't know, maybe 39) [e.g. 11.6.0-39U SysNAND, 11.6.0-39J EmuNAND]

Entrypoint (How/what you're using to boot Luma3DS): Boot9Strap [e.g. Boot9Strap/Sighax, etc.]

Luma3DS version: SysNAND 9.1 (The latest) [e.g. 8.1.1 stable or if using nightly/hourly specify the commit like this https://github.com/AuroraWright/Luma3DS/commit/9570e6cbeca53128433abbf5e3473cb8a07fe69e]

Luma3DS configuration/options:

Default EmuNAND: ( )

Screen brightness: ( )

Splash: ( x)

PIN lock: ( )

New 3DS CPU: ( )

--

Autoboot EmuNAND: ( )

Use EmuNAND FIRM if booting with R: ( )

Enable loading external FIRMs and modules: ( )

Enable game patching: ( x)

Show NAND or user string in System Settings: (x )

Show GBA boot screen in patched AGB_FIRM: ( x)

Patch ARM9 access: ( )

Set developer UNITINFO: ( )

Disable ARM11 exception handlers: ( )

--

Explanation of the issue:

I have an 1551099374948221607358 Old 2DS. If I switch console to sleep mode, than turn DS on and open Rosalina Menu at the same moment, console will NOT exit the SleepMode. The only way is to reboot console by holding "power" button 1551099435136908216531

Steps to reproduce:

1. Turn ON sleep mode on Old 2DS 2. Turn the sleep mode OFF and open Rosalina Menu at the same time

Dump file:

Nemris commented 5 years ago

I noticed a similar bug. On an Old3DS with Luma built as of commit f718297591976b01d3530769d12da68636a689f6, the console would randomly stay in sleep mode as OP described, the only way to turn it off being holding Power.

OS version: 11.9.0-42E.

profi200 commented 5 years ago

Try to press B to exit (the invisible) Rosalina menu.

Nemris commented 5 years ago

Didn't work here, because the device was locked into sleep mode.

profi200 commented 5 years ago

Ok. Not sure if it's worth fixing a problem like that. There is no way you can accidentally hit all required buttons.

TuxSH commented 5 years ago

Make sure you haven't activated the rosalina menu before going into sleep mode.

Additionally, this hang will happen if you have (had?) enabled InputRedirection or the gdb server. I've tried many things in attempt to fix that long-standing issue, to no avail.

Nemris commented 5 years ago

@TuxSH I compiled Luma3DS v9.1-b05f9932, and was able to reproduce the bug on an Old3DS, v11.9.0-42E.

Boot it, open and close Rosalina, then close and open the lid until you get locked into sleep mode. The only way to exit it is to hold Power.

TuxSH commented 5 years ago

Do blue light filters work for you or do they leave you with a black screen?

If it's the latter, I think I've fixed the issue ~1h ago.

Nemris commented 5 years ago

Blue light filters work. I can build the latest commit and see if the bug is solved, if it helps.

Edit: as of Luma v9.1-02023674, the sleep mode bug still happens.

urherenow commented 5 years ago

Using latest ctrulib and Luma3ds commits, I keep getting conflicting types errors trying to compile loader.c FSREG_LoadProgram FSREG_GetProgramInfo FSREG_Register FSREG_RegisterProgram

TuxSH commented 5 years ago

@urherenow that's normal, use latest ctrulib release

Skirlez commented 5 years ago

Took a build from here:https://github.com/hax0kartik/luma-hourlies/releases 150-luma3ds-474eb30 Did exactly what OP said, and the 2DS was locked in sleep mode. but when I tried pressing the B button, the system woke up. So i guess its fixed?

TuxSH commented 5 years ago

which commit breaks it?

ghost commented 5 years ago

is this a o2ds only thing

TuxSH commented 5 years ago

I can only repro it on my o2ds, I think it could be related to a bug in my custom sm reimpl (notifications and/or edge-case handling)... I need to investigate

Nemris commented 5 years ago

@TuxSH The bug occurs on my New3DS as well. I could try my hand at bisecting, if it helps identifying the offending commit.

Edit: according to git bisect, the bad commit is any of

I was forced to skip some commits because building Rosalina failed.

TuxSH commented 5 years ago

Can you retry with e2ed2005095cc4d9621af5bfed5fe7271c5ac19c?

Nemris commented 5 years ago

No differences, the bug exhibits the same behavior.

profi200 commented 5 years ago

Not related to this issue but i figured i should mention this: There is a bug since the sm reimplementation was introduced that makes the camera applet crash when the camera is already in use (for example by pausing 3DS camera). Normally it would just say it's already in use.

TuxSH commented 5 years ago

urgh, edge case handling an APT. Wouldn't be surprised if it worked with official sm only because the latter's impl is so broken.

I should probably rewrite the main loop and hope the bug isn't elsewhere...

I guess next release will next much more time than I thought ... :p

Nemris commented 5 years ago

I'm available to test commits as they're out.

TuxSH commented 5 years ago

@profi200 Fixed your bug in https://github.com/AuroraWright/Luma3DS/commit/8345f31c2a120a06d35e32bf85b5379613945968

DMSalesman: does it fix yours?

My build, to be sure: boot.firm.zip

Nemris commented 5 years ago

The bug is still here.

TuxSH commented 5 years ago

What if you remove sm in sysmodules/Makefile and rebuild?

Nemris commented 5 years ago

I'll try and report back in a while.

Nemris commented 5 years ago

The sm sysmodule is clean. The bug is elsewhere.

TuxSH commented 5 years ago

Can you comment this line and rebuild: https://github.com/AuroraWright/Luma3DS/blob/master/sysmodules/rosalina/source/main.c#L144 ?

Nemris commented 5 years ago

You got it this time: commenting lines 144 and 150 seems to solve the bug.

TuxSH commented 5 years ago

so the issue are the blue light filters restore-after-sleep functionality (EDIT). I think I know what's happening, hang on...

Nemris commented 5 years ago

Interestingly, I tried to apply a filter and it worked fine.

Edit: got it. Waiting.

TuxSH commented 5 years ago

What if you try to comment the screenFiltersSetTemperature(screenFiltersCurrentTemperature); line only? (btw, I'm going to switch to latest commit ctrulib soon enough)

Nemris commented 5 years ago

Yeah, everything works fine. Whatever it is, it's in that function.

TuxSH commented 5 years ago

what if you significantly increase the timeout in the above svcSleepThread call?

Nemris commented 5 years ago

I replaced the 16 with a bunch of values, the most significant being 24, 32 and 64. The first and last values randomly locked the 3DS in sleep mode without even having to open Rosalina once. The middle one gave me the exact same bug we have now, if not for the slower resuming from sleep mode.

TuxSH commented 5 years ago

What if you increase it even more, e.g to 200ms?

Nemris commented 5 years ago

100ms and 200ms lock the 3DS in sleep mode as soon as I close the lid. This happens without firing up Rosalina even once.

TuxSH commented 5 years ago

Eh. I'd have expected it to work around the issue.

Anyway, it seems like sleep mode is really finicky... the bug can be, but is not limited to, a race condition between rosalina and gsp, and it seems like stuff is timing-sensitive as well.

I think the best option here is to simply remove the "auto restore screenfilter on wakeup" feature.

Nemris commented 5 years ago

It's a half victory, so let's go for it. It's been a fun ride, anyway.

TuxSH commented 5 years ago

Thanks for your testing help :)