Flow switch is probably going bad and starting to stick.its a pressure switch by the heating element. If you lose water flow the heater shuts off to protect the heating element from overheating.
on my tub changing the switch is a like a 10 min job. You'll need basic hand tools and some teflon tape.