Skip to main content
March 3, 2009
Question

Air application not closing correctly

  • March 3, 2009
  • 12 replies
  • 4811 views
Hello,

I'm working on an AIR project for a client and I'm having a problem: some testers reported that after closing the application they can still see the application running in the task manager using about 50% of the cpu.

From what we where able to see, this problem is present only in Windows XP SP2. If the same application is run on XP SP3 or Mac the application exits as expected.

If the application is opened again, a new instance of the application is visible in the task manager. After closing it both the instances remain in the task manager.

We noticed also that this behavior happens only after the application starts loading data from a web server using a URLLoader. (so far the problem was reported if the application was closed after the request but before the reply of the server, but we are still looking into this)

We tried calling the Close method of the URLLoader before shutting down the application or calling explicitly the NativeApplication.nativeApplication.exit(), but this doesn't affect the outcome.

Can someone suggest a way for us to troubleshoot this?

Thank you very much
Andrea
This topic has been closed for replies.

12 replies

Participating Frequently
November 17, 2011

Hi there, i had such problem too and the code given by coolkams didnt work for me.

Here is what i did :

First thing i want to know the the main app is activated:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, onAppactivation);

Then the callback function add a CLOSE event listener to the current active window wich is the main application window:

private function onAppactivation(e:Event):void

{

    NativeApplication.nativeApplication.removeEventListener(Event.ACTIVATE, onAppactivation);

    NativeApplication.nativeApplication.activeWindow.addEventListener(Event.CLOSE, applicationExit);

}

Finnaly in the CLOSE event callback function :

private function applicationExit(e:Event):void

{

    e.currentTarget.removeEventListener(Event.CLOSE, applicationExit);

     NativeApplication.nativeApplication.exit();

}

That did the trick for me, hope it will help other people too...

July 17, 2009

Use the following code to close the application properly.

        public function applicationExit():void
        {
            var exitingEvent:Event = new Event(Event.EXITING, false, true);
            NativeApplication.nativeApplication.dispatchEvent(exitingEvent);
            if (!exitingEvent.isDefaultPrevented()) {
                NativeApplication.nativeApplication.exit();
            }
        }

call this funciton by using the close event in <mx:WindowedApplication close="applicationExit()">


More details about this can be found here: http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118676a5d46-8000.html

June 1, 2009

I found out an another way to trigger this bug that does not terminate program correctly. Here a way to reproduce the bug:

Start an AIR application, let it load.

Go to your taskbar on the bottom of the screen and find you AIR application there.

Right click on that AIR application

Click Close

Open up your task manager and go to Processes

After you closed it as mentioned above, your AIR program is actually still running in the process list even tho it got closed. It should have been terminated but it never did due this bug.

I tested this bug on Window XP service pack 2 and Window Vista Service Pack 1. Both are affected.  I have not be able to test this on Mac OS X.

If you trigger this bug, your program wont be able to rerun again unless you reboot your computer or log off/log back in.

I have not report this bug yet.

No solution yet except tell the user not to right click -> close as mentioned above...

Adobe Employee
June 2, 2009

I can't reproduce this problem.

-ted

June 2, 2009

What operating system are you running? In Window Vista service pack 2, it

doesn’t reproduce the bug anymore... Maybe same for XP service pack 3...The

test was based on Ajax made applications.

Adobe Employee
March 5, 2009
Thanks for filing the bug.

The AIR bug database could not be seen from outside, not like the Flex bug database.

I will post here if I find out it is accepted or rejected.

-ted
June 1, 2009

Were there any further developments on this bug report? I am having the same issues, only from what I see it's also on XP Service Pack 3, and haven't really found any solutions.

Adobe Employee
March 3, 2009
Could you file a bug at:
http://www.adobe.com/go/wish/
?
It would be very helpful if you can include a simple program that shows the problem.

Thanks,

ted
Damon Edwards
Inspiring
March 4, 2009
I notice this in my own application quite often. After exiting, it sometimes takes upwards of 2 minutes before the system try icon will go away and its process is terminated. This even happens in ADL. Another weird thing with this is that sometimes just rolling the mouse over the system tray icon will remove it and terminate the process.