Skip to content

Context.startForegroundService() did not then call Service.startForeground() #2010

Closed

Description

@AndyScherzinger

Highest number of reports for ANRs since 2.0.0 in the Dev console - Android 8 only - >5K reports in 60 days

Reason I found google-ing: https://stackoverflow.com/questions/44425584/context-startforegroundservice-did-not-then-call-service-startforeground

From Google's docs on Android 8.0 behavior changes:
The system allows apps to call Context.startForegroundService() even while the app is in the background. However, the app must call that service's startForeground() method within five seconds after the service is created.

--> https://developer.android.com/about/versions/oreo/android-8.0-changes.html

************ CAUSE OF ERROR ************

android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{fb59be8 u0 com.nextcloud.client/com.owncloud.android.services.OperationsService}
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1745)
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:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

************ APP INFORMATION ************
ID: com.nextcloud.client
Version: 30080190
Build flavor: generic

************ DEVICE INFORMATION ************
Brand: lge
Device: joan
Model: LG-H932
Id: PQ3A.190605.003
Product: joan_tmo_us

************ FIRMWARE ************
SDK: 28
Release: 9
Incremental: eng.markus.20190610.202830

Activity

  1. paulpv commented on Mar 21, 2018

    @paulpv
  2. dark-chocolate commented on Jan 2, 2019

    @dark-chocolate

    @AndyScherzinger Have you guys found some solution for this?

  3. AndyScherzinger commented on Jan 2, 2019

    @AndyScherzinger
    MemberAuthor

    Not that I am aware of

  4. stale commented on May 9, 2019

    @stale

    This request did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

  5. tobiasKaminsky commented on Oct 9, 2019

    @tobiasKaminsky
    Member

    Re-opening as there are some new reports, and this is the issue with most background infos.

  6. tobiasKaminsky commented on Oct 9, 2019

    @tobiasKaminsky
    Member

    @ALL when is this happening?
    We use startForegroundService() on

    • upload file
    • document storage provider
    • sync folder
    • sync file
  7. AndyScherzinger commented on Oct 30, 2019

    @AndyScherzinger
    MemberAuthor
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{9cb193 u0 com.nextcloud.client/com.owncloud.android.services.OperationsService}
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2126)
    	at android.os.Handler.dispatchMessage(Handler.java:112)
    	at android.os.Looper.loop(Looper.java:216)
    	at android.app.ActivityThread.main(ActivityThread.java:7625)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
    
    ************ APP INFORMATION ************
    ID: com.nextcloud.client
    Version: 30080190
    Build flavor: gplay
    
    ************ DEVICE INFORMATION ************
    Brand: HONOR
    Device: HWBKL
    Model: BKL-L09
    Id: HUAWEIBKL-L09S
    Product: BKL-L09
    
    ************ FIRMWARE ************
    SDK: 28
    Release: 9
    Incremental: 329C432
    
    
  8. AndyScherzinger commented on Oct 30, 2019

    @AndyScherzinger
    MemberAuthor
    ************ CAUSE OF ERROR ************
    
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{bd2d535 u0 com.nextcloud.client/com.owncloud.android.services.OperationsService}
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1855)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6990)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
    
    ************ APP INFORMATION ************
    ID: com.nextcloud.client
    Version: 30080190
    Build flavor: gplay
    
    ************ DEVICE INFORMATION ************
    Brand: samsung
    Device: crownlte
    Model: SM-N960F
    Id: PPR1.180610.011
    Product: crownltexx
    
    ************ FIRMWARE ************
    SDK: 28
    Release: 9
    Incremental: N960FXXS3CSI5
    
  9. AndyScherzinger commented on Oct 30, 2019

    @AndyScherzinger
    MemberAuthor
    ************ CAUSE OF ERROR ************
    
    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{a4dde14 u0 com.nextcloud.client/com.owncloud.android.services.OperationsService}
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2126)
    at android.os.Handler.dispatchMessage(Handler.java:112)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7625)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
    
    ************ APP INFORMATION ************
    ID: com.nextcloud.client
    Version: 30080190
    Build flavor: gplay
    
    ************ DEVICE INFORMATION ************
    Brand: HONOR
    Device: HWBKL
    Model: BKL-L09
    Id: HUAWEIBKL-L09S
    Product: BKL-L09
    
    ************ FIRMWARE ************
    SDK: 28
    Release: 9
    Incremental: 329C432
    
  10. 15 remaining items

  11. InfamousUser commented on Sep 17, 2020

    @InfamousUser

    Google Pixel 2. I do get a lot of ANRs and app stopped in the background when it is uploading. I plug the charger in (which triggers autoupload) and it pops up every so often. I think it slowed down on the last RC1 release or penultimate release, I had the app force stopped for several months because it was unusable so I wasn't paying so much attention anymore. If you need any more details I'm happy to help get this resolved for me and everyone who might be having the same issue.

    Edit: It basically always displays homescreen (I assume this is same as "crash") while using the app if I go to uploads and try to scroll around. I should have said that it doesn't always crash if I don't try to scroll. When I scroll it freezes and displays homescreen after maybe 10 seconds, then homescreen is just a picture, none of the on-screen controls work for next 20 or so seconds, then it displays ANR but at this point it has kicked me out of the app, the app isn't usable and phone isn't usable for at least 30 seconds. And then sometimes it displays that crash text on next app start, most often it doesn't (does that mean that it hasn't crash or not idk) but it kicks me out of the app.

    Also the uploads take like 10-15 seconds per single file (they're very small files), whole auto-upload seems very slow.

  12. tobiasKaminsky commented on Sep 18, 2020

    @tobiasKaminsky
    Member

    Can you see how many pending uploads you have?
    While it can happen that the app does not respond (ANR) it should not kill using rest of your device.
    Can you reboot, make sure that none other apps are open and see if this somehow performs better?

  13. InfamousUser commented on Sep 19, 2020

    @InfamousUser

    There's about 120, there's always around that number, it goes through them one by one. If I keep the uploads menu open, it goes towards zero slowly, it's very slow, I never actually waited more than until maybe 70. But when I'm not on that tab/I'm in the background, it queues the uploads up to around 110-120 queued. Sometimes if I don't touch anything, it keeps showing that screen and slowly uploading (approx. 0.1 item/s), if I try to scroll, it lags/freezes and eventually crashes/doesn't respond.

    I tried the following: close all the apps from the recent or overview or whateverItsCalled list, reboot, wait until it fully powers up and starts, then wait 2 mins to make sure it has stabilized, still nothing in recent apps list. I then open Nextcloud, go to uploads, it now "waits to exit power saving mode", I plug the charger in and it goes out of power saving mode and starts uploading -> Nextcloud immediately crashes to begin with. Then I open up Nextcloud and go to uploads menu, it freezes again, whole OS doesn't respond to input, power button will work and fingerprint sensor works to turn off and on the phone, but the touchscreen interface is frozen, after about 20 seconds it unlocks and I get to use my phone again.

    I have not turned off any background apps or services, it would be a humongous pain to enumerate and disable (if they can be disabled) all the apps that run without me opening them.

    Amusingly it says that Nextcloud has stopped/keeps stopping but I cannot interact with the dialogue box to close it because Nextcloud is keeping the phone from being used for half a minute until it's ready to be used again.

    As a side question, as you are developer, is there any way to close and prevent apps from opening by themselves in Android? I mean I can try to close them but some apps turn right back on in the background.

  14. InfamousUser commented on Nov 14, 2020

    @InfamousUser

    Still happening on 3.14 RC2. Just opened the app to find one file.

  15. tobiasKaminsky commented on Nov 17, 2020

    @tobiasKaminsky
    Member

    There is an APK file in PR #7340, which you can install in parallel to your existing Nextcloud app.
    It would be great if you can verify the fix.

  16. willpyshan13 commented on Nov 19, 2020

    @willpyshan13

    when i remove a file it will be appear

    in version stable-3.14.0

  17. InfamousUser commented on Nov 20, 2020

    @InfamousUser

    Finally this is getting fixed! Good job everyone!

  18. AndyScherzinger commented on Nov 20, 2020

    @AndyScherzinger
    MemberAuthor

    @InfamousUser to be sure please try the QA build in #7340 if you can spare some time 🙏

  19. InfamousUser commented on Nov 21, 2020

    @InfamousUser

    @InfamousUser to be sure please try the QA build in #7340 if you can spare some time 🙏

    Yeah, sure. I updated over the previous QA version and it seems to behave the same as described in this comment:
    #7340 (comment).
    and here
    #7378 (comment)

    In essence, the original problem seems fixed, only receiving ANRs all the time now.

  20. InfamousUser commented on Jan 12, 2021

    @InfamousUser

    I'm afraid to say it's still happening on 3.14.2 RC1 for FileUploader.

  21. InfamousUser commented on Jan 13, 2021

    @InfamousUser

    ************ CAUSE OF ERROR ************

    android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{933be3d u0 com.nextcloud.client/com.owncloud.android.files.services.FileUploader}
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2005)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

  22. InfamousUser commented on Feb 1, 2021

    @InfamousUser

    Still happening on 3.15.0 RC1. Please reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions