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

Got an ANR(Application Not Responding) error #37

Closed
LaurieWuAndroid opened this issue May 10, 2022 · 8 comments
Closed

Got an ANR(Application Not Responding) error #37

LaurieWuAndroid opened this issue May 10, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@LaurieWuAndroid
Copy link

Environment

  • Android OS version: 12
  • Devices affected: Samsung Galaxy S10e
  • Search SDK Version: v1.0.0-beta.28
  • Included in project Maps SDK, Nav SDK versions if available: Maps SDK: v9.6.1

Code examples

SDK initialization:

        applicationScope.launch(dispatcher.main()) {
            Mapbox.getInstance(
                this@HatchApplication,
                getString(hatch.features.rewards.R.string.mapbox_access_token),
            )
        }
        applicationScope.launch(dispatcher.io()) {
            MapboxSearchSdk.initialize(
                this@HatchApplication,
                getString(hatch.features.rewards.R.string.mapbox_access_token),
                DefaultLocationProvider(this@HatchApplication)
            )
        }

querySuggestion:

        return withContext(dispatchers.main()) {
            suspendCancellableCoroutine { cont ->
                val callback = object : SearchSelectionCallback {
                    override fun onCategoryResult(
                        suggestion: SearchSuggestion,
                        results: List<SearchResult>,
                        responseInfo: ResponseInfo,
                    ) = Unit

                    override fun onResult(
                        suggestion: SearchSuggestion,
                        result: SearchResult,
                        responseInfo: ResponseInfo,
                    ) = Unit

                    override fun onError(e: Exception) = cont.resume(Err(e))

                    override fun onSuggestions(suggestions: List<SearchSuggestion>, responseInfo: ResponseInfo) {
                        cont.resume(Ok(suggestions))
                    }
                }
                searchTask?.cancel()
                val options = proximity?.let { searchOptions.copy(proximity = it) } ?: searchOptions
                searchTask = mapboxPlaceSearch.search(query.toString(), options, callback)
            }
        }

Observed behavior and steps

run app, wait for app to launch, observes this error on logcat as the app hangs and remains unresponsive.

2022-05-10 11:09:09.114 772-787/? E/ActivityManager: ANR in com.hatchcard.android.debug
    PID: 8787
    Reason: executing service com.hatchcard.android.debug/com.mapbox.android.telemetry.MapboxTelemetryService
    Load: 14.62 / 9.89 / 4.09
    CPU usage from 7613ms to 0ms ago (2022-05-10 11:08:58.758 to 2022-05-10 11:09:06.372):
      9.8% 8102/com.google.android.calendar: 8.9% user + 0.9% kernel / faults: 6720 minor
      2.6% 772/system_server: 1.1% user + 1.4% kernel / faults: 33 minor
      1.1% 8787/com.hatchcard.android.debug: 0.9% user + 0.2% kernel / faults: 119 minor
      0.7% 1505/com.android.systemui: 0.5% user + 0.2% kernel / faults: 27 minor
      0.6% 417/kworker/u16:4: 0% user + 0.6% kernel
      0.5% 432/surfaceflinger: 0.2% user + 0.2% kernel
      0% 5375/kworker/1:3: 0% user + 0% kernel
      0.3% 430/msm_irqbalance: 0.1% user + 0.2% kernel
      0.3% 6121/com.google.android.apps.turbo:aab: 0.2% user + 0.1% kernel / faults: 86 minor
      0.2% 10/rcu_preempt: 0% user + 0.2% kernel
      0.2% 31/kworker/0:1: 0% user + 0.2% kernel
      0.2% 38/kworker/u16:1: 0% user + 0.2% kernel
      0.2% 302/msm-core:sampli: 0% user + 0.2% kernel
      0.2% 426/android.hardware.wifi@1.0-service: 0.1% user + 0.1% kernel
      0.2% 484/irq/215-fc38800: 0% user + 0.2% kernel
      0.2% 573/thermal-engine: 0% user + 0.2% kernel
      0.1% 3/ksoftirqd/0: 0% user + 0.1% kernel
      0.1% 15/ksoftirqd/1: 0% user + 0.1% kernel
      0.1% 16/kworker/1:0: 0% user + 0.1% kernel
      0.1% 25/ksoftirqd/3: 0% user + 0.1% kernel
      0% 35/kworker/1:1H: 0% user + 0% kernel
      0.1% 40/kworker/u17:0: 0% user + 0.1% kernel
      0.1% 42/kworker/u17:1: 0% user + 0.1% kernel
      0.1% 161/vsync_retire_wo: 0% user + 0.1% kernel
      0.1% 205/spi5: 0% user + 0.1% kernel
      0.1% 209/kworker/u16:3: 0% user + 0.1% kernel
      0.1% 250/cfinteractive: 0% user + 0.1% kernel
      0.1% 259/mmcqd/0: 0% user + 0.1% kernel
      0.1% 331/ueventd: 0% user + 0.1% kernel
      0.1% 346/kworker/u17:3: 0% user + 0.1% kernel
      0.1% 349/kworker/u17:5: 0% user + 0.1% kernel
      0.1% 368/logd: 0% user + 0.1% kernel
      0.1% 427/healthd: 0% user + 0.1% kernel
      0.1% 431/lmkd: 0% user + 0.1% kernel
      0.1% 564/jbd2/dm-2-8: 0% user + 0.1% kernel
      0.1% 596/wificond: 0% user + 0.1% kernel
      0.1% 2503/com.google.android.gms.persistent: 0.1% user + 0% kernel / faults: 1 minor
      0.1% 3860/com.agilebits.onepassword: 0.1% user + 0% kernel / faults: 1 minor
      0.1% 5386/kworker/0:5: 0% user + 0.1% kernel
      0.1% 6936/kworker/3:3: 0% user + 0.1% kernel
      0.1% 7244/com.google.android.youtube: 0.1% user + 0% kernel
      0.1% 8060/com.google.android.apps.walletnfcrel: 0.1% user + 0% kernel / faults: 1 minor
      0.1% 8592/com.lilly.deloitte.vega: 0.1% user + 0% kernel / faults: 4 minor
      0.1% 8856/com.google.android.gms.unstable: 0.1% user + 0% kernel / faults: 10 minor
    3% TOTAL: 1.7% user + 0.8% kernel + 0% iowait + 0.3% softirq
    CPU usage from 79ms to 499ms later (2022-05-10 11:09:06.450 to 2022-05-10 11:09:06.870):
      36% 772/system_server: 12% user + 24% kernel / faults: 403 minor
        39% 787/ActivityManager: 15% user + 24% kernel
        3% 772/system_server: 3% user + 0% kernel
      2.4% 44/irq/51-cpr: 0% user + 2.4% kernel
      2.6% 259/mmcqd/0: 0% user + 2.6% kernel
      3.1% 2503/com.google.android.gms.persistent: 0% user + 3.1% kernel / faults: 1 minor
        3.1% 2503/.gms.persistent: 0% user + 3.1% kernel
      3.9% 8787/com.hatchcard.android.debug: 3.9% user + 0% kernel
        3.9% 8815/plumber-android: 3.9% user + 0% kernel
    7.8% TOTAL: 2.7% user + 5.1% kernel
2022-05-10 11:09:27.066 772-792/? E/BatteryExternalStatsWorker: no controller energy info supplied for bluetooth
2022-05-10 11:10:27.016 2503-3356/? E/baqn: Phenotype API error. Event # cvpe@65c4bb15, EventCode: 5 [CONTEXT service_id=51 ]
    bapp: 29501: Stale snapshot for com.google.android.libraries.consentverifier#com.google.android.tts(change count changed - expected 17  but was 16)
        at baqs.b(:com.google.android.gms@221514019@22.15.14 (040400-441847897):14)
        at baqq.g(:com.google.android.gms@221514019@22.15.14 (040400-441847897):0)
        at baqn.e(:com.google.android.gms@221514019@22.15.14 (040400-441847897):4)
        at baqn.f(:com.google.android.gms@221514019@22.15.14 (040400-441847897):2)
        at agzc.en(:com.google.android.gms@221514019@22.15.14 (040400-441847897):1)
        at agzi.run(:com.google.android.gms@221514019@22.15.14 (040400-441847897):11)
        at cdcj.run(:com.google.android.gms@221514019@22.15.14 (040400-441847897):2)
        at xyb.c(:com.google.android.gms@221514019@22.15.14 (040400-441847897):6)
        at xyb.run(:com.google.android.gms@221514019@22.15.14 (040400-441847897):7)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at ydg.run(:com.google.android.gms@221514019@22.15.14 (040400-441847897):0)
        at java.lang.Thread.run(Thread.java:764)

Expected behavior

able to see login screen, proceed to login, take user input on button clicks after login.

@LaurieWuAndroid LaurieWuAndroid added the bug Something isn't working label May 10, 2022
@LaurieWuAndroid
Copy link
Author

LaurieWuAndroid commented May 11, 2022

would love to get some help with this, ASAP(during work hours) as this might be blocking development. 🙏🏼

@DzmitryFomchyn
Copy link
Contributor

Hey @LaurieWuAndroid,
Very sorry to hear that you've faced with this issue.

As I see, you're using quite an old version of Maps SDKv9.6.1 and we don't guarantee compatibility with the new Search SDK.

Will you be able to migrate to Maps v10 and pick one of the latest versions of the Maps SDK https://github.com/mapbox/mapbox-maps-android/releases?

Also, I'm curious why are you initializing Search SDK on a IO dispatcher? Any reason for that?

        applicationScope.launch(dispatcher.io()) {
            MapboxSearchSdk.initialize(
                this@HatchApplication,
                getString(hatch.features.rewards.R.string.mapbox_access_token),
                DefaultLocationProvider(this@HatchApplication)
            )
        }

@LaurieWuAndroid
Copy link
Author

Hi @DzmitryFomchyn thanks for the speedy response! I tried to switch to higher mapbox version(10.2.0, 10.5.0), it results in build error Unable to make private void java.util.concurrent.CopyOnWriteArrayList.writeObject(java.io.ObjectOutputStream) throws java.io.IOException accessible: module java.base does not "opens java.util.concurrent" to unnamed module @29fc2153

In response to your question on IO dispatcher, we're trying to init the sdk off the main thread, so that process doesn't block user input and freeze the app.

@DzmitryFomchyn
Copy link
Contributor

Unable to make private void java.util.concurrent.CopyOnWriteArrayList.writeObject(java.io.ObjectOutputStream) throws java.io.IOException accessible: module java.base does not "opens java.util.concurrent" to unnamed module @29fc2153

Hmm, that's a very strange bug and we haven't seen this before in any of Mapbox SDKs. Could you please share a full error log? Also, it would be very helpful if you could share a test project that shows this bug.

In response to your question on IO dispatcher, we're trying to init the sdk off the main thread, so that process doesn't block user input and freeze the app

Did you notice that Search SDK initialization slows down app startup?

@LaurieWuAndroid
Copy link
Author

Hmm, that's a very strange bug and we haven't seen this before in any of Mapbox SDKs. Could you please share a full error log? Also, it would be very helpful if you could share a test project that shows this bug.

We had to revert a chunk of code for now to unblock development, thus this issue is not as urgent now. I love the idea, though not sure if my schedule allows. I will try my best to follow up on this as I find more info.

Did you notice that Search SDK initialization slows down app startup?

Not that I noticed, since this code was already implemented, but it is also good practice to have any initialization that might take a long time to be in the background thread.

@kalbaxa
Copy link
Contributor

kalbaxa commented May 13, 2022

I will try my best to follow up on this as I find more info.

@LaurieWuAndroid should we close it for now then? Feel free to reopen as new info is encountered.

@LaurieWuAndroid
Copy link
Author

LaurieWuAndroid commented May 13, 2022

I will try my best to follow up on this as I find more info.

@LaurieWuAndroid should we close it for now then? Feel free to reopen as new info is encountered.

I'm okay with that 😃, thank you!

@DzmitryFomchyn
Copy link
Contributor

I'm closing the issue. Feel free to reopen it or create a new one if you have more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants