Welcome to Android Central.
Not sure what you tried but it brings up a few questions.
Are you doing anything in particular when this happens? Any particular app you're using, trying to split screen multi-task, running a Bixby routine, anything you can think of that would tie the happenings together?
Are there any error messages associated with this happening? Maybe even one after the restart?
Using the phone in Safe Mode is a pain depending on what you want to do but have you spent anytime in Safe Mode? Did it ever freeze on you then?
Have you cleared the cache partition for the device? This requires restarting the phone to the bootloader screen, not a cache you can clear from the settings menus.
Have you cleared the caches for your system apps? I would get an app like Ccleaner, or one you trust, from the Play Store and doing an overall cache clearing. I mention Ccleaner because I know it will include system apps as well as your regular apps.
You say it started 7 months ago, so has it gotten worse now or did it take you this long to get tired of it? It would have been better to mention it sooner rather than later because it may have been something that you installed but looking back now it's doubtful that you remember anything you may have installed at that time or other changes that were made.
To reply to this thread and receive notifications when others leave replies, please create an account. This link will help you do that... https://forums.androidcentral.com/ask-question/409154-join-android-central-community-new-post.html