ndeadly / MissionControl

Use controllers from other consoles natively on your Nintendo Switch via Bluetooth. No dongles or other external hardware neccessary.
GNU General Public License v2.0
2.51k stars 139 forks source link

Wake from sleep reboot #323

Closed Uhane closed 2 years ago

Uhane commented 3 years ago

After pairing a ps4 dualshock, putting the system to sleep would cause it to boot to atmosphere splash screen on wake. Recopying atmosphere didn't solve the issue. Deleted /atmosphere/contents/010000000000bd00 and /atmosphere/exefs_patches/bluetooth_patches and /config/MissionControl but problem persisted. Sleep function returned to normal once I wiped the pairing database. I think I had everything installed but no controller connected and the sleep function worked normally. Would appear to be something with the database.

Using current builds of Hekate, Atmosphere and running 12.1.0 on sysmmc

ndeadly commented 3 years ago

Was there an atmosphere fatal error screen or anything shown? If so, post the crash report here.

I've seen an issue a few times where the console will crash after going to sleep with a DS4 controller still connected. I believe it's due to the controller taking longer to disconnect than expected and a timeout triggers the crash. This is a rather rare issue though, with only a couple of people having reported it, and I've never seen it myself since early development days.

The fact that you're having an issue after removing mission control is interesting though. Which other custom sysmodules do you have installed? You're not using it in conjunction with nx-btred by any chance are you? I'm also not really sure how the bluetooth pairing database could be linked to a crash in any way.

In any case, I think I would need to see a crash report in order to investigate further.

Uhane commented 3 years ago

No crash, sorry. More like the when waking from sleep it would reboot instead, would also happen when undocking the switch as well. Not sure if it was actually in sleep mode or if it was shutting off instead. I think the battery was draining while it was off, but I'm not sure.

I did have nx-btred installed but couldn't get it working so I deleted it and that also seems to have fixed this sleep mode issue. I reinstalled mission control and it works fine now. I could try to recreate the problem if you can pull any valuable information but again, there was no crash report.

Thank you for your help and all the work you put into this.

ndeadly commented 3 years ago

The reason I asked about nx-btred is because it makes use of mission controls Bluetooth event redirection feature. This allows the btpair app to receive the pairing related events instead of the OS. Last I checked there was no safeguard in plutooo's app to catch the user exiting with the home button, which means the app can be exited without cancelling the event redirection and the system will stop receiving Bluetooth events. When this happens you will get crashes when the system goes to sleep. Maybe a reboot is possible too.

Without a crash report it's harder to pinpoint an issue, so there may not be much point in messing about if you've got it working now. However, if you wanted to try and see if you could recreate the problem and could figure out the condition under which it occurs that could be useful information to have.

brandon-dodds commented 3 years ago

I too had issues in regards to nx-btred causing a sleep mode restart on Atmosphere. I personally thought it was MissionControl though since I installed it after nx-btred.

impeeza commented 3 years ago

nx-btred cannot work without Mission Control, nx-btred is like a "plugin" for mission control.

for me I have been able to reproduce, going to any homebrew on Hombrew launcher and then trying to run any full game, the switch get a completely black screen (with the backlight on) and after 30 seconds of the power button pressed when I turn on the switch and inject the Hekate payload, the hekate logo is showed and the switch turn off again (as configured on NYX for response to RTC events) then on a new start of switch after inject the payload, all works fine.

ndeadly commented 3 years ago

I too had issues in regards to nx-btred causing a sleep mode restart on Atmosphere. I personally thought it was MissionControl though since I installed it after nx-btred.

Technically it is mission control causing the sleep issues in the scenario I mentioned in my post above, as it is responsible for blocking the bluetooth events from the system. But it's the btpair app that comes with nx-btred that is enabling the event redirection in the first place, and likely not disabling it under certain circumstances. Without mission control installed this app will give an error, but is also unable to screw up the events and cause a crash/restart.

nx-btred cannot work without Mission Control, nx-btred is like a "plugin" for mission control.

This is incorrect. nx-btred (the sysmodule) can absolutely work without mission control. It's the btpair app that requires it for the event redirection feature I mentioned above. After the headphones are paired, it should be possible to remove mission control, assuming that headphones will reconnect automatically (don't know, never installed nx-btred before).

The reason mission control is a dependency is because a mitm of the bluetooth service is neccessary to capture the bluetooth event handles that make pairing possible. If plutooo had implemented this himself, he would not only have been reinventing something I had already written, but nx-btred would also have ended up incompatible with mission control as there can only be one mitm installed per service

impeeza commented 3 years ago

oh, thank you so much for the explanation, and for all your work. regards