-
16 Feb 2013 4:44 AM #1
Answered: [FREQ] Multiple instance of same app on Linux & Windows
Answered: [FREQ] Multiple instance of same app on Linux & Windows
Hello,
I just found there is an issue with the packaged version for Windows (7) and Linux (Ubuntu).
If I try to open my app on MacOS, everything is ok, I can see the window and supposing I'm going to minimize it, than to restore by clicking on the app icon (in Application folder), the same window will be restored (same instance/window).
Doing it with Ubuntu / Windows, the OS will create multiple instances/windows of same app.
Is it normal behaviour? Am I missing something during the packaging task? How to avoid this?
Thank you
-
Best Answer Posted by jarrednicholls
This is actually expected behavior, not a "bug"...though if you wish it not to happen, this is certainly a valid concern. A little background:
OS X uses a "new window" paradigm, where an application bundle runs only a single instance of itself, but the user can create new windows for fresh "instances" of the same app, for example...just like creating a new window of Safari or Chrome.
On Windows & Linux, the same process can have multiple running instances, which is totally a valid occurrence and often times desired. For example, Sencha Architect can have multiple instances running if a user wants to work on multiple projects at the same time. When Desktop Packager multi-window support comes around, the need for multiple instances will be gone.
Fortunately, you can use the same technique that a lot of applications implement on Windows & Linux to force a single-running instance, as a stop gap until we decide to make this a configuration option. In your main startup JavaScript code, you can run Ion.sys.exec() on Windows & Linux to query for a list of running processes on the system. If there is more than one running instance in that list, you can call Ion.app.exit() to quit the process. Pseudo-code would look something like this:
I'll create a ticket for this request for adding in this ability on the runtime side as a config option. Thanks!Code:var exeName = 'MyApp', processes; if (Ion.sys.os === 'windows') { processes = Ion.sys.exec('tasklist'); exeName += '.exe'; } else if (Ion.sys.os === 'linux') { processes = Ion.sys.exec('ps -A'); } if (numMatches(processes, exeName) > 1) { Ion.app.exit(/* optional error code here */); }
-
20 Feb 2013 8:27 AM #2Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
- Answers
- 20
This is actually expected behavior, not a "bug"...though if you wish it not to happen, this is certainly a valid concern. A little background:
OS X uses a "new window" paradigm, where an application bundle runs only a single instance of itself, but the user can create new windows for fresh "instances" of the same app, for example...just like creating a new window of Safari or Chrome.
On Windows & Linux, the same process can have multiple running instances, which is totally a valid occurrence and often times desired. For example, Sencha Architect can have multiple instances running if a user wants to work on multiple projects at the same time. When Desktop Packager multi-window support comes around, the need for multiple instances will be gone.
Fortunately, you can use the same technique that a lot of applications implement on Windows & Linux to force a single-running instance, as a stop gap until we decide to make this a configuration option. In your main startup JavaScript code, you can run Ion.sys.exec() on Windows & Linux to query for a list of running processes on the system. If there is more than one running instance in that list, you can call Ion.app.exit() to quit the process. Pseudo-code would look something like this:
I'll create a ticket for this request for adding in this ability on the runtime side as a config option. Thanks!Code:var exeName = 'MyApp', processes; if (Ion.sys.os === 'windows') { processes = Ion.sys.exec('tasklist'); exeName += '.exe'; } else if (Ion.sys.os === 'linux') { processes = Ion.sys.exec('ps -A'); } if (numMatches(processes, exeName) > 1) { Ion.app.exit(/* optional error code here */); }
-
20 Feb 2013 8:48 AM #3
I was thinking about this solution but I was a little scared about this kind of process handling.
Thank you for your answer.
-
21 Feb 2013 3:19 AM #4
You found a bug! We've classified it as
ION-1037
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote