That does not rule out hardware issues. Since it appears to be a repeatable error you would be back to the maker or carrier to show them the error and see how they intend to fix it.
Hope it's in warranty since OOW (out of warranty) repairs are usually the end.
PS. I see you posted before so I won't duplicate the ideas there here.
My Galaxy Note 8 Front Camera Hangs and unfortunately stops when i convert it from rear to front/selfie mode.. some times it works for few seconds.. i had done many techniques .. reset camera setting.. rest my phone as well.. try to check in safe mode.. but it didn't work..
its not hardware fault because when i open it in service test mode *#0*# it works properly.