Mac: "Launching" app when it's already open doesn't put it in foreground #2616
Comments
Without knowing PyInstaller well enough, I suspect it is because of the way it launches. When starting an app built with PyInstaller, it spawns a new process: I am guessing the parent process (19285) sets up the environment, and the child process does the actual GUI display. I suspect that macOS only "sees" the parent process, thinks it doesn't have a GUI and is thus unable to "switch to it". Or, it could be caused by the parent process "Not Responding" in the screenshot. |
PyInstaller already uses a single process for windows. I'm not sure what py2app does, but if you're familiar with C, then you could look at changing this for mac. This additional complexity comes from --onefile, but it shouldn't affect --onedir. |
Possibly relevant: pyi_parent_to_background called by bootloader in the child process. |
So @xoviat do you think the problem could be solved by simply moving the |
You could try changing it to |
Amazing. That works!
My app runs perfectly fine with this change - and the "not coming to foreground" issue is fixed. I'll create a PR to get this merged (or at least reviewed) by PyInstaller. Thanks @xoviat! |
Wow! I did not expect it to be that easy! |
On Mac, launching an application that's already open puts it in the foreground. This didn't work for apps built with PyInstaller because of the parent -> subprocess structure at runtime. The present commit fixes the problem for --onedir mode by using a single process. Closes #2616.
On Mac, launching an application that's already open puts it in the foreground. This didn't work for apps built with PyInstaller because of the parent -> subprocess structure at runtime. The present commit fixes the problem for --onedir mode by using a single process. Closes pyinstaller#2616.
Unfortunately this issue is only partially fixed as reopening still does not work in |
On macOS, launching applications when they are already open puts them in the foreground. For instance:
This also works with apps built with py2app:
But it doesn't work with apps built with PyInstaller. Proceeding from the above command line:
I am encountering exactly the same problem with a PyQt5 app I'm working on. So the problem is not specific to PyObjC.
The text was updated successfully, but these errors were encountered: