Helium314 / Local-NLP-Backend

Yet another network location backend for the UnifiedNLP/microG project
GNU General Public License v3.0
65 stars 4 forks source link

Crash : java.lang.NullPointerException at BackendService.backgroundProcessing #24

Open Massedil opened 5 months ago

Massedil commented 5 months ago

Version : 1.2.11 F-Droid Android 14 / LineageOS 21 on Samsung A52s

FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: helium314.localbackend, PID: 29126
java.lang.NullPointerException
at org.fitchfamily.android.dejavu.BackendService.backgroundProcessing(BackendService.kt:754)
at org.fitchfamily.android.dejavu.BackendService.access$backgroundProcessing(BackendService.kt:50)
at org.fitchfamily.android.dejavu.BackendService$queueForProcessing$1.invokeSuspend(BackendService.kt:724)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@2a57992, Dispatchers.IO]
Helium314 commented 5 months ago

when does it happen?

Massedil commented 5 months ago

Good question. Don't really know.

Here, location freshly activated for a Bluetooth Low Energy usage. I have launched a Bluetooth scan in this app.

I think it is here it crashes.

Massedil commented 5 months ago

I also think I crashes if I'm on Airplane mode and use location in OSMAnd app, for example. But not sure it is always crashing doing this.

Helium314 commented 5 months ago

Interesting... the line in question is https://github.com/Helium314/Local-NLP-Backend/blob/main/app/src/main/java/org/fitchfamily/android/dejavu/BackendService.kt#L754 Looks like emitterCache is null, but it's actually used just a few lines above, where it's definitely not null (the crash would happen already there if it was).

Massedil commented 5 months ago

Looks like emitterCache is null,

Or observation.identification ?

Helium314 commented 5 months ago

Observations are in observations: Collection<Observation>, which as far as I understand Kotlin cannot contain null elements. If the observation was null, then the crash should happen when adding to the collection. observation.identification also is not nullable.

EmitterCache is the only thing that can be null, but should only be null if the service is being closed while backgroundProcessing is running. This is why I was asking when the crash happens. If it's when closing, then it simply shouldn't matter.

Massedil commented 5 months ago

This is why I was asking when the crash happens. If it's when closing, then it simply shouldn't matter.

I was not using the app. The app should have been started in background when I activated the location.