Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13444 closed Bug Report - General (Fixed)

Android recover from long sleep

Reported by: mspieth Owned by: Mark Spieth
Priority: minor Milestone: 31.0
Component: Ports - Android Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

When sleeping for a while on android (shield in particular) when the shield wakes up, the screen is black and wont redraw.

Attachments (4)

2019040701_android-recover-from-sleep-1.patch (2.4 KB) - added by mspieth 5 years ago.
20190415-android-suspend-fix.patch (1.9 KB) - added by mspieth 5 years ago.
20190417-android-suspend-pause-bookmark.patch (2.8 KB) - added by gigem 5 years ago.
20190418-android-suspend-pause-bookmark.patch (2.9 KB) - added by gigem 5 years ago.

Download all attachments as: .zip

Change History (19)

Changed 5 years ago by mspieth

comment:1 Changed 5 years ago by mspieth

Added patch which seems to have worked when I paused playback overnight.

We will see.

comment:2 Changed 5 years ago by mspieth

Doesnt work

root cause is probably related to this

https://groups.google.com/forum/#!topic/android-ndk/jwVMF6zINus

investigating

comment:3 Changed 5 years ago by mspieth

More info

https://conf.qtcon.org/system/attachments/132/original/QtCon16.pdf%3F1473147092 for android.app.splash_screen_sticky

also https://stackoverflow.com/questions/31523403/qt-5-android-change-background-running-value-to-true to fix the timer not working correctly when the app is in the background. Will need to track the state of the app and not do any UI stuff during background state.

Yet to be tested.

Changed 5 years ago by mspieth

comment:4 Changed 5 years ago by mspieth

Added new patch for main repo.

Disregard previous patch.

Not yet tested but builds.

Version 0, edited 5 years ago by mspieth (next)

comment:5 Changed 5 years ago by Mark Spieth <mspieth@…>

In 9de7b0f21d/mythtv:

Handle ApplicationStateChanged? event in android for suspension

refs #13444

comment:6 Changed 5 years ago by Mark Spieth <mspieth@…>

In 9de7b0f21d/mythtv:

Handle ApplicationStateChanged? event in android for suspension

refs #13444

Changed 5 years ago by gigem

comment:7 Changed 5 years ago by gigem

Added a new patch to automatically pause and set a bookmark when suspending and undo them when resuming.

comment:8 in reply to:  7 ; Changed 5 years ago by mspieth

Replying to gigem:

Added a new patch to automatically pause and set a bookmark when suspending and undo them when resuming.

Do you have to set background_running in the manifest too?

Otherwise LGTM with the above true.

The other way to do it would be to add a listener for ApplicationStateChanged? in the tv class. While sendEvent QAPP_SUSPEND is synchronous, it does go through the dispatcher on the main QT thread. If this is already stopped in no background_running mode, then this may break the handling of QAPP_SUSPEND until the app goes back into foreground.

comment:9 in reply to:  8 Changed 5 years ago by gigem

Replying to mspieth:

Do you have to set background_running in the manifest too?

Yes, the way it currently works using MythEvents?.

Background running is also currently needed for other reasons. Any screens that use events to update their state need it. They would all have to be changed to support a "refresh everything" operation after being resumed. Some would likely be easy to do that while others less so. It's something we can continue to work towards if we want to. Background music playing would definitely need to keep background running.

Otherwise LGTM with the above true.

The other way to do it would be to add a listener for ApplicationStateChanged? in the tv class. While sendEvent QAPP_SUSPEND is synchronous, it does go through the dispatcher on the main QT thread. If this is already stopped in no background_running mode, then this may break the handling of QAPP_SUSPEND until the app goes back into foreground.

I wasn't sure if multiple listeners for ApplicationStateChanged? would work. I can try it. Can any Q_Object listen for it? I went with what I was more familiar with (MythEVents) and what I was confident would work.

Changed 5 years ago by gigem

comment:10 Changed 5 years ago by gigem

Added revised patch using signals and slots instead of MythEventMessages?. Also added member variable denoting when we are suspended. This might be needed to avoid a race condition if suspension occurs during TV startup. If would help if someone familiar with TV startup could take a look at that.

comment:11 Changed 5 years ago by mspieth

This one looks fine to me too.

If you think the MythEvents? version is better and we can guarantee background running then that version is fine too.

Commit either as you see fit but don't forget the Manifest change too with the first one.

Sorry for not mentioning this sooner to eliminate waste/churn.

comment:12 Changed 5 years ago by gigem

I'll likely go with the latest patch since it's slightly more direct. I still would like Mark Kendall to review it before committing. He might have a better idea and might also comment on the race condition part I mentioned.

The manifest part is already committed. I did that two days ago. As mentioned, it's still needed unless and until multiple screens are updated to perform full refreshes after being suspended for potentially long periods of time.

comment:13 Changed 5 years ago by David Engel <dengel@…>

In 94bffc30a5/mythtv:

Pause playback and set a bookmark when suspended on Android.

Also, clear the bookmark and unpause playback when resumed.

Refs #13444

comment:14 Changed 5 years ago by mspieth

Resolution: Fixed
Status: newclosed

comment:15 Changed 5 years ago by Stuart Auchterlonie

Milestone: needs_triage31.0
Note: See TracTickets for help on using tickets.