3 Replies
      Latest reply on Dec 19, 2019 1:46 PM by deelydian
      adomasven Level 1 Level 1 (0 points)

        In the current Safari App Extension framework the background Swift process can be removed by the OS at any point while Safari is still running. This creates multiple issues:

        1. You cannot store any state about the tab in the background, which is neccessary if you want to update the button label and icon, or context menu options based on the state of the tab

        2. There may be a big delay between user pressing the extension button and any visible response, since the background app extension process needs to be reinitialized if it got killed.

         

        My question is whether there is a way to maintain the background app extension process running for as long as Safari itself is open and/or would that be considered bad practice? If it is, what would be the way to mitigate the issues outlined above?

        • Re: Maintain the background process running as long as the Safari process is alive
          deelydian Level 1 Level 1 (0 points)

          Were you able to get a solution for this issue @adomasven? I believe I'm running into something similar where Safari closes after about 30 seconds of running the extension. For development, there definitely needs to be some sort of flag we can set to force the Safari instance to stay open. For production, we would need some way to listen for the extension being closed so we could reinstantiate it if needed. Like the OP said, we don't know how long the delay will be for a user interacting with the code in the extension, and if it's closed, there's no way to rerun it, so far as I know.

           

          Does anyone have any information on how to keep the extension running? Is there any events we can tie into in order to hear when it closes and then respond accordingly? If so, how do we go about reinstantiating the exension if it's closed?