microg / microg/IchnaeaNlpBackend

"No instance found active" in first several runs

Open
#51 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
124
Forks
29
PR merge metrics
No merged PRs in 30d

Description

I refer to [this post](https://github.com/lineageos4microg/android_prebuilts_prebuiltapks/issues/22#issuecomment-544442041) for a background, especially a [filtered logcat](https://github.com/lineageos4microg/android_prebuilts_prebuiltapks/files/3750031/lc_filtered.txt).

MozillaNlpBackend version 1.4.0 with microG version 0.2.8.17785-4 (06c8b76)

When Mozilla Nlp backend is (firstly) enabled in UnifiedNlp, there are messages in logcat: `IchnaeaBackendService: No instance found active.` The backend gives the location only after a long period and maybe the repeated re-enablings are also necessary.

After searching in codes, I found that the only place to print this message is in the member function `reloadInstanceSettings()` when `instance == null`. Note that
1. `instance` is a private static variable which is written only by protected member functions `onOpen()` and `onClose()`, as far as I understand.
2. `reloadInstanceSettings()` is a public member function. However, among member functions, only `onCreate()` calls it.

This seems to be illogical. The `instance` could only be set to a non-null value by `onOpen()`. That is to say, every call to `onCreate()` would have failed with `No instance found active.` before the first call of `onOpen()` - this is a plausible reason why Ichnaea does not work once enabled in UnifiedNlp. Other backends do not share a similar issue under the same circumstance. Especially if we compare the code `onCreate()` here and that in [Apple WiFi Nlp Backend](https://github.com/microg/AppleWifiNlpBackend/blob/c8b039f170c1e18066a2f8e57aa3fea127dc98f3/src/main/java/org/microg/nlp/backend/apple/BackendService.java#L96), we see that `onCreate()` there does not check any analog of `instance`.

Contributor guide

No contributing guide indexed for this repository

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

Inspect the Ichnaea backend service around reloadInstanceSettings(), onCreate(), onOpen(), and onClose(), then compare its lifecycle handling with the linked Apple WiFi Nlp Backend implementation. Use the linked filtered logcat as the reproduction reference; done should mean first-time enablement no longer reports an inactive instance and location becomes available without repeated re-enabling.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
backend, mobile-dev
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.