Game freezes with sodium while on advanced optimus

When I put my display mode on auto select, and whenever I switch apps, minecraft(with sodium) freezes, I can still hear button sounds, which means the game is still running, but all i see is the pause screen. I tried playing on vanilla and fabric without sodium and everything worked fine. I know putting display mode to gpu only or optimus would help, but it shouldnt be a solution to me cuz i dont wanna switch between display modes everytime i wanna play minecraft. Does anyone have a solution to this problem?