Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for new Version and release 0.21.12 #7232

Merged
merged 2 commits into from
Oct 12, 2021
Merged

Conversation

TobiGr
Copy link
Member

@TobiGr TobiGr commented Oct 12, 2021

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

The service for checking for a new NewPipe version was started too early when the app was still in background sometimes.
Starting the service is now moved from App.onCreate() to MainActivity.onCreate().

Fixes the following issue(s)

Fixes #7227

APK testing

Testing this with debug applications does not work. Take the APK from #7227 (comment)

Due diligence

@TobiGr TobiGr added bug Issue is related to a bug ASAP Issue needs to be fixed as soon as possible labels Oct 12, 2021
@TobiGr TobiGr changed the base branch from dev to master October 12, 2021 13:51
When the service is started from the Application class, the app might be still in the background. This is definetly not the case when MainActivity.onCreate() is called.

Fixes #7227
Copy link
Member

@Redirion Redirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm and already tested in linked issue

@TobiGr TobiGr merged commit 7eb13a9 into master Oct 12, 2021
@TobiGr TobiGr deleted the release/0.21.12 branch October 12, 2021 17:15
@TobiGr
Copy link
Member Author

TobiGr commented Oct 17, 2021

I got this one again: the phone had battery save mode enabled.

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: DE
  • Content Language: de
  • App Language: en
  • Service: none
  • Version: 0.21.12
  • OS: Linux Android 9 - 28
Crash log

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.schabi.newpipe/org.schabi.newpipe.MainActivity}: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=org.schabi.newpipe/.CheckForNewAppVersion }: app is in background uid UidRecord{2488b6b u0a131 CAC  bg:+10h9m26s804ms idle change:idle procs:1 seq(702,702,702)}
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
	at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:4823)
	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4732)
	at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
	at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:55)
	at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:4782)
	at android.app.ActivityThread.access$3200(ActivityThread.java:200)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1826)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6718)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=org.schabi.newpipe/.CheckForNewAppVersion }: app is in background uid UidRecord{2488b6b u0a131 CAC  bg:+10h9m26s804ms idle change:idle procs:1 seq(702,702,702)}
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
	at android.app.ContextImpl.startService(ContextImpl.java:1532)
	at android.content.ContextWrapper.startService(ContextWrapper.java:664)
	at org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService(CheckForNewAppVersion.java:241)
	at org.schabi.newpipe.MainActivity.onCreate(MainActivity.java:170)
	at android.app.Activity.performCreate(Activity.java:7144)
	at android.app.Activity.performCreate(Activity.java:7135)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
	... 16 more


@TobiGr
Copy link
Member Author

TobiGr commented Oct 17, 2021

I think we need to put this into onResume().
https://developer.android.com/guide/components/activities/activity-lifecycle#onresume

When the activity enters the Resumed state, it comes to the foreground, and then the system invokes the onResume() callback.

@Redirion
Copy link
Member

This would be executed many times then though

@TobiGr
Copy link
Member Author

TobiGr commented Oct 17, 2021

I tried to circumvent this. See #7268

@TobiGr TobiGr mentioned this pull request Oct 21, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASAP Issue needs to be fixed as soon as possible bug Issue is related to a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not allowed to start service Intent in startNewVersionCheckService at app start
2 participants