NativeScript / NativeScript/plugins

@nativescript/background-http high number of crashes

Open
#274 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
206
Forks
123
Avg merge
2d 1h
Merged PRs (30d)
1

Description

I am seeing a lot of crashes with java.lang.IllegalArgumentException when calling net.gotev.uploadservice.UploadServiceConfig.getNamespace

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4673)
  at android.app.ActivityThread.access$1700 (ActivityThread.java:301)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2196)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:246)
  at android.app.ActivityThread.main (ActivityThread.java:8653)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.IllegalArgumentException: 
  at net.gotev.uploadservice.UploadServiceConfig.getNamespace (UploadServiceConfig.kt:74)
  at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationAction (UploadServiceConfig.kt:234)
  at net.gotev.uploadservice.UploadServiceConfig.getBroadcastNotificationActionIntentFilter (UploadServiceConfig.kt:248)
  at net.gotev.uploadservice.observer.request.NotificationActionsObserver.register (NotificationActionsObserver.kt:31)
  at net.gotev.uploadservice.UploadService.onCreate (UploadService.kt:194)
  at android.app.ActivityThread.handleCreateService (ActivityThread.java:4661)

Other people seem to be having this issue as well (https://github.com/Vydia/react-native-background-upload/issues/288), the proposed solution is to use net.gotev:uploadservice-okhttp:4.7.0, which background-http already uses. There are some mentions in other threads that it might be due to not creating a notification channel which is supposed to happen here https://github.com/NativeScript/plugins/blob/ca9e56ae814c670f9c603157a3fe7eb70c9bbbea/packages/background-http/index.android.ts#L8

But I suspect it's not being called reliably since it's tied to application launch.
@triniwiz does it need to be strictly called on launch? Is it okay to check didInit when creating a session and if it hasn't initialised, try to do so?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading packages/background-http/index.android.ts, especially the notification-channel initialization and didInit state, then trace how a session is created. Confirm whether initialization can be skipped before UploadService starts, and use the reported UploadServiceConfig crash as the failure case; done means sessions initialize reliably without this crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.