What causes my Macbook to spontaneously shut down? Out of the blue today, my Macbook Pro 2015 15", running macOS Catalina 10.15.2, shut down while I was using it.

Since then, for the past half hour or so, I haven't been able to keep it on for longer than a minute or so. It either spontaneously shuts down, requiring me to manually turn it back on, or it spontaneously restarts. Now (a day later) it only spontaneously shuts down. It doesn't restart itself.

This happens when it is plugged into the charger and when it is simply running on battery. This also happens while only headphones are connected to the MacBook, or while no peripherals are connected.

Apple Diagnostics shows "No issues found."

I have tried resetting SMC and NVRAM.

Additionally, when starting up I notice weird graphical glitches, for example a white bar sometimes appears on the left side of the screen, or the apple logo repeatedly resizes itself, or a regular pattern of white rectangles appears across the whole screen.

I got a picture of that:



This flashes onto the screen after the first apple logo appears.

The Macbook does not spontaneously shut down or restart when I boot it into Recovery Mode or Safe Mode.

However, there are also graphical glitches in both of these modes; look at the terminal tabs in Recovery Mode:




Moving the mouse cursor over the tabs causes them to scintillate randomly, rectangular monochrome patterns. and glitches.

Exactly the same graphical glitch happens to Finder tabs in Safe Mode.

Why does my Macbook restart like that after I've booted it normally? How do I resolve this problem?
Your symptoms are either a bad driver / os for the video subsystem or a hardware failure. 

In case of hardware, safe mode will often run since it doesn’t ask as much of the video system which runs in a fail safe / basic mode. Also, it can slow down the rendering so you can easily see the failure modes or grab a screen shot. 

Before paying for a repair, consider charting how often this happens and back up / erase install to be sure this is the hardware / vram failing. 

As to the shutdown, unless there’s a severe failure, you should get. A kernel panic, but if the logs show no events and no panics, then that’s another reason to suspect hardware failure. 

Since your mac won’t run more than 5 minutes in normal mode, why not back it up in safe mode and try an erase install. If your Mac can’t reinstall itself, then you know it’s repair time. If it can, you’ll be back in business