hardware – My phone stops responding sometimes after the screen goes off

my phone is a Motorola G5S+, with a custom ROM installed (you’ll understand later why that is not of much relevance). Randomly, after my screen goes off (and granted that the phone isn’t actively doing anything like a call) the whole phone stops responding. That includes the power/volume buttons, fingerprint scanner, every gesture (like shaking to turn on/off the flashlight) and even the usb port (charging it or connecting to a computer does nothing, the computer doesn’t even detect the phone).

This started happening after I updated a custom ROM (PE11 March to PE11 April) (not the first time I installed it from scratch, but the first time I received an update) but, after installing several different ROMs over the past week, I highly doubt it’s a software problem.

The reason why I switched ROMs the first time was because, after this problem appearing a few times (note: this happens once or twice a day), the last time I had to force reset the phone by holding the power button for a few secs, after the reset the OS, or the UI at least, was dead. The phone screen did turn on, although it was a black screen, all buttons and gestures worked except for the fingerprint scanner and the phone was charging (or at least it was doing the sound it does when you plug it in).

That led me to go in a ROM-switching frenzy, but as you might’ve guessed, the problem kept appearing. I even went back to the first ROM (PE11 March update) wherein this problem had not yet occurred but, of course, now it did happen.

I wanna point out two things:

that my usb cable is not working properly and hasn’t been for a while now, but this is much more recent than my defective USB, but one of my theories is that this is an electrical problem, but I hope it’s not.

that when the phone is unresponsive, it is NOT turned off. I know this since the first time this problem arised, my flashlight was on and it didn’t turn off (nor could I until after I had forced the phone to reset). Also because it takes a lot longer for the screen to turn back on after it dies, meaning that the phone is “waiting” for me to hold the power button for long enough.