[Interest] Make Android App Restart When It Can't Resume Quickly

David Engel david at istwok.net
Tue Sep 25 18:13:13 CEST 2018


I've been continuing to plug away at this problem as time allows.

Recently, I determined that during the lengthy resumes, one and
sometimes two threads are using 100% cpu.  One of those threads is
always thread 1 as reported by gdb.  Whenever I stop the app and look,
that thread is always in __epoll_pwait which is called by
epoll_pwait().  I suspect it's the Qt event loop or some sort of
Android/Qt interface thread.  Unfortunately, I don't seem to have the
appropriate debug symbols in my Qt libraries to confirm that.  gdb
simply reports the callers as "??  ()".

I'm trying to build Qt libraries with the necessary debug information.
It's either not getting included in the first place or getting
stripped somewhere along the way.  I first tried adding "-debug" to the
Qt configure command but that resulted in the following error at
run-time:

09-24 13:30:31.042 22577 22597 F libmythfrontend.so: /home/david/src/mythtv/android/packaging/android/libs64/qt-everywhere-src-5.10.1/qtbase/src/gui/kernel/qguiapplication.cpp:1156 (void init_platform(const QString&, const QString&, const QString&, int&, char**)): This application failed to start because it could not find or load the Qt platform plugin "android"

Does anyone have any other ideas how to find out what thread 1 is and
what it might be doing to cause it to use 100% cpu for several
minutes?

David

On Wed, Aug 08, 2018 at 09:46:59AM -0500, David Engel wrote:
> Hi Petar,
> 
> A private reply also pointed out to me that the long resume times I
> see are highly unusual.  I'm starting to change my focus now to
> understanding why that is happening in the first place.
> 
> I'll check those activity options again.  The last time I looked, they
> didn't sound like what I wanted, but it won't hurt to try.  I have
> tried android:noHistory (always causes a restart when true) and
> android:stateNotNeeded (didn't seem to have any real effect).
> 
> We're currently using Qt 5.10.1.  One of the other MythTV developers
> is looking into updating that to 5.11.
> 
> David
> 
> On Wed, Aug 08, 2018 at 01:28:05PM +0200, Petar Koretić wrote:
> > Hi David.
> > 
> > For the past 3-4 years I've been actively doing Android/Qt development and
> > I have never had such an issue.
> > On many different Android boxes, TVs and phones I haven't had something
> > like that, not even on Nvidia shield.
> > Resume always happens in a matter of seconds even after standby or long
> > time being in background.
> > You could play around with options like setting true for
> > android:alwaysRetainTaskState or changing android:launchMode.
> > I would develop and test basic Android/Qt app to see what happens in your
> > case and then go from there.
> > 
> > Which Qt version are you using?
> > 
> > Best regards,
> > Petar
> > 
> > 
> > On Wed, Aug 8, 2018 at 8:47 AM René Hansen <renehh at gmail.com> wrote:
> > 
> > > As far as I know, Kodi is open source. So is their Android client:
> > >
> > > https://kodi.wiki/view/Android_development
> > >
> > > Maybe check it out for inspiration.
> > >
> > >
> > > /René
> > >
> > > On Tue, 7 Aug 2018 at 21:35 David Engel <david at istwok.net> wrote:
> > >
> > >> Hi,
> > >>
> > >> I'm one of the developers of the MythTV, open source DVR.  Over the
> > >> last several months, we've ported our frontend (aka client) from Linux
> > >> with Qt to run on Android with Qt.  It's to the point now that some of
> > >> us are using Nvidia Shield TVs as our primary frontends.
> > >>
> > >> One annoying problem that remains is that resuming the app can
> > >> sometimes take several minutes.  By resume I mean switching back to
> > >> the app after the device has been sleeping for several hours or other
> > >> apps have been in use.  I know Android doesn't have traditional swap
> > >> like Linux, so I can only assume that the Android system and/or the Qt
> > >> framework is saving and restoring significant process state somewhere.
> > >> What I'd like to do is have our app resume where it was but only if
> > >> that can be done in a few seconds.  If it can't resume quickly, then
> > >> want it to disregard any previous state and restart.  How can I do
> > >> that?  Other apps like Kodi seem to work that way, but I can't figure
> > >> out how they do it.
> > >>
> > >> Thanks,
> > >> David
> > >> --
> > >> David Engel
> > >> david at istwok.net
> > >> _______________________________________________
> > >> Interest mailing list
> > >> Interest at qt-project.org
> > >> http://lists.qt-project.org/mailman/listinfo/interest
> > >>
> > > _______________________________________________
> > > Interest mailing list
> > > Interest at qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/interest
> > >
> 
> -- 
> David Engel
> david at istwok.net
> 

-- 
David Engel
david at istwok.net



More information about the Interest mailing list