question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON Reader AssertionError when doInBackground (Android 7, 8)

See original GitHub issue

Hi guys, in latest Lottie Android version (2.5.0) we are having several crashes at doInBackground() method. This crash is only happening on Android 7 and 8 versions.

Here is our animation preloading code:

class LottieAnimations {

    companion object {

        @JvmStatic
        var willyWaiting: LottieAnimation? = null
        var specialBonusCollectCoins: LottieAnimation? = null
        var specialBonusCollectGems: LottieAnimation? = null

        @JvmStatic
        fun load(context: Context) {
            fromAssetFileName(context, "animation/waiting_lottie/data.json") {
                it?.let { willyWaiting = LottieAnimation(it, "animation/waiting_lottie/images") }
            }

            fromAssetFileName(context, "animation/special_bonus_collect_coins/data.json") {
                it?.let { specialBonusCollectCoins = LottieAnimation(it, "animation/special_bonus_collect_coins/images") }
            }

            fromAssetFileName(context, "animation/special_bonus_collect_gems/data.json") {
                it?.let { specialBonusCollectGems = LottieAnimation(it, "animation/special_bonus_collect_gems/images") }
            }
        }
    }

}

Here is the StackTrace:

OS Version: 8.0.0 Device: Xperia X RAM Free: 38.5% Disk Free: 60.8%

#0. Crashed: AsyncTask #4 at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.#util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Caused by java.lang.AssertionError at android.util.JsonReader.peek(JsonReader.java:363) at android.util.JsonReader.expect(JsonReader.java:308) at android.util.JsonReader.beginObject(JsonReader.java:293) at com.airbnb.lottie.parser.LottieCompositionParser.parse(SourceFile:42) at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(SourceFile:269) at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(SourceFile:22) at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(SourceFile:12) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

#0. Crashed: AsyncTask #4 at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

#1. pool-2-thread-1 at java.lang.Object.wait(Object.java) at java.lang.Thread.parkFor$(Thread.java:2135) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1087) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

#2. httpThread at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:375) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:65)

#3. ConnectivityThread at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:375) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:65)

#4. pool-3-thread-1 at java.lang.Object.wait(Object.java) at java.lang.Thread.parkFor$(Thread.java:2135) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2059) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1120) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1087) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Any ideas?

Tnx in advance

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:52

github_iconTop GitHub Comments

12reactions
TobiasReichcommented, Aug 13, 2018

We are having the same issues (Lottie 2.5.5) - only Android 8. So hope to find a fix soon.

Caused by java.lang.AssertionError
       at android.util.JsonReader.peek(JsonReader.java:363)
       at android.util.JsonReader.expect(JsonReader.java:308)
       at android.util.JsonReader.beginObject(JsonReader.java:293)
       at com.airbnb.lottie.parser.LottieCompositionParser.parse(LottieCompositionParser.java:42)
       at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(LottieComposition.java:276)
       at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:22)
       at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:12)
       at android.os.AsyncTask$2.call(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)

I’m aware this is probably an Android issue (not Lottie) but perhaps you could add an option of wrapping this in a try-catch block or something so not the whole app crashes when this happens?!

4reactions
awengercommented, May 17, 2018

We don’t use lottie-android, but see a similar crash in our app:

Fatal Exception: java.lang.AssertionError
       at android.util.JsonReader.peek(JsonReader.java:363)
       ...

So far we only observed crashes on devices with 8.0.0 and 8.1.0. I currently assume it is a bug in JsonReader, so I opened a bug report here: https://issuetracker.google.com/issues/79920590

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
JSON Reader AssertionError when doInBackground (Android 7, 8)
Read more >
android - AsyncTask giving error at runInBackground - Stack Overflow
Use this in postExecute()(overridden method) method inside the class Message ListAdapter adapter = new SimpleAdapter(this, contactList, R.layout.list_item, ...
Read more >
AsyncTask - Android Developers
On this page; Developer Guides; Usage; AsyncTask's generic types; The 4 steps; Cancelling a task; Threading rules; Memory observability; Order of execution ...
Read more >
Java Examples for android.util.JsonReader - Javatips.net
This java examples will help you to understand the usage of android.util.JsonReader. These source code samples are taken from different open source ...
Read more >
java.lang.assertionerror: async not started - You.com | The search ...
AssertionError 14901-21 10:44:37.221 29312 29503 E AndroidRuntime: at android.util.JsonReader.peek(JsonReader.java:363) 15001-21 10:44:37.221 29312 29503 E ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found