KhoalaS / Infinity-For-Reddit

A Reddit client for Android
https://play.google.com/store/apps/details?id=ml.docilealligator.infinityforreddit
GNU Affero General Public License v3.0
310 stars 13 forks source link

Crash when opening full post, only on some posts #18

Closed emmaexe closed 10 months ago

emmaexe commented 10 months ago

Checklist

App version

5.11.0

Where did you get the app from

Other

Android version

MIUI Global 14.0.5 (Android 12 SKQ1.211019.001)

Device model

Poco X3 NFC

First occurred

Recently, unsure exactly when since it does not happen on all posts

Steps to reproduce

  1. Find a post that crashes when opened fully
  2. Open post, and see that the app crashes

Example post, link, markdown...

https://www.reddit.com/r/MadeMeSmile/comments/17i55ro/oc_my_son_thinks_that_semi_trucks_are_life_it/

Expected behaviour

Post loads normally

Current behaviour

App crashes

Logs

2 Examples:

java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
    at ml.docilealligator.infinityforreddit.utils.Utils.inlineImages(Utils.java:92)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseSingleComment(ParseComment.java:268)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:189)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:196)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:196)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.lambda$parseComment$1(ParseComment.java:39)
    at ml.docilealligator.infinityforreddit.comment.ParseComment$$ExternalSyntheticLambda4.run(Unknown Source:8)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONArray.length()' on a null object reference
    at ml.docilealligator.infinityforreddit.utils.Utils.inlineImages(Utils.java:92)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseSingleComment(ParseComment.java:268)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:189)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:196)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.parseCommentRecursion(ParseComment.java:196)
    at ml.docilealligator.infinityforreddit.comment.ParseComment.lambda$parseComment$1(ParseComment.java:39)
    at ml.docilealligator.infinityforreddit.comment.ParseComment$$ExternalSyntheticLambda4.run(Unknown Source:8)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
emmaexe commented 10 months ago

After looking at the post a little, I found this comment which might be the cause: https://www.reddit.com/r/MadeMeSmile/comments/17i55ro/comment/k6sbd3v/?utm_source=share&utm_medium=web2x&context=3

It seems reddit introduced "collectible expressions" recently: https://www.reddit.com/r/modnews/comments/17b00ch/introducing_collectible_expressions/

Not sure if that is the cause, but it might be it.

emmaexe commented 10 months ago

Also tested this with the same post on the original infinity, which does not have the inline image rendering and it works fine there.

emmaexe commented 10 months ago

From logcat:

E/MARKWON-IMAGE: Error loading image: avatar_exp|147939568|bravo
    java.lang.IllegalStateException: No scheme is found: avatar_exp|147939568|bravo
        at io.noties.markwon.image.AsyncDrawableLoaderImpl$1.run(AsyncDrawableLoaderImpl.java:96)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
        at java.lang.Thread.run(Thread.java:1012)

Occurs when attempting to render the collectible expressions comment

KhoalaS commented 10 months ago

Will look into it 👍

KhoalaS commented 10 months ago

Temp fix in a557246