PWA in Safari A2HS iPad breaks if opening a link and return to the PWA app

My PWA app running in Safari iOS 14.7.1 breaks if opening a link from the PWA app and then returning to the pwa app. The app is launched from a home screen icon. Everything works correctly until I open a link from the app and then return to the pwa app. It might be related to use of a javascript alert function?

My PWA code works correctly including being able to open a link and return to the pwa afterwards if running the pwa in the Edge browser. Seems only to be broken if using Safari? And then only if tapping on a link to another page or url and returning to my app afterwards..from then on there are errors and dysfunction in my pwa app. Any ideas why and how to work around? Thank you.

New information: My PWA runs fine a day later after a fresh reboot..no issue after opening a link from within my PWA then returning to the PWA. But then "later in the day" it seems to get corrupted again if opening a link then returning to the PWA. Its almost as though indexedDB storage memory gets corrupted by the opened link? Is indexedDB memory not isolated from the rest of Safari browser memory..or is it all shared? This did not seem to be a problem in earlier versions prior to iOS14.6? I am currently running iOS14.7.1 on an iPad Pro 9.7". My PWA also runs with no issues in the Edge browser…except Edge for iOS does not have a A2HS option! So might this be a bug in the latest Safari or I am afraid more likely a bug in my code but I am at a loss as to how to fix it. I suspect a javascript Alert function might play a part? My code also uses an indexedDB function to fetch the current database files in Safari indexedDB storage. But why does my code work most of the time and why does it work everytime in Edge? Any one experienced similar problems. How well does Safari iOS support PWAs? Any suggestion or work around would be much appreciated! Thank you for reading this!

For me it is still not working.

PWA in Safari A2HS iPad breaks if opening a link and return to the PWA app
 
 
Q