Sounds like an Application level library is needed, rather than an Activity?
 
Sent: Tuesday, October 27, 2015 at 11:49 AM
From: "Preet via Interest" <[email protected]>
To: "<[email protected]>" <[email protected]>
Subject: [Interest] Qt on Android and loading native libs
I recently came across an issue with native code on Android (not in a Qt application though). When an Activity loads shared libraries, those libraries aren't unloaded by Android until the corresponding process is killed. However, Android can keep the same process around while creating multiple instances of an Activity.
 
So it seems like the main QtActivity may be created and destroyed multiple times with the same process (unless something I did't catch is being done to prevent this). If shared libraries aren't loaded/unloaded accordingly, you would be starting up your native application with any global state in the shared libraries left intact.
 
I think that to compensate for this, Qt unloads the shared library that contains the 'main' function. You can see this in androidjnimain.cpp, in the startMainMethod function where dlclose is called on whichever native lib contains the 'main' symbol. I'm not entirely sure that dlclose is being called explicitly for this purpose though. After that, finish() is called on the Activity.
 
This should work in general but there's this edge case where another instance of an Activity can be created *before* the previous one is destroyed. 
 
So imagine: 
00:01: [QtActivity1 onCreate] 
00:02: [QtActivity1 onPause] 
00:03: [QtActivity2 onCreate]
00:04: [QtActivity1 onStop,Destroy,whatever]
 
Does qt do anything to prevent or deal with that case?
 
 
Preet
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to