oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

FAQs crashes in RTL(psuedolocale)

Open FareesHussain opened this issue 4 years ago • 7 comments

Describe the bug FAQ crashes in Psuedolocale

To Reproduce Steps to reproduce the behavior:

  1. Set language to Psuedolocale
  2. Open 'Navigation Drawer'
  3. Click on 'Help'
  4. Open FAQs
  5. Click on any of the following questions
    • How can I create a new profile?
    • How can I delete a profile?
    • Why is the Exploration player not loading?
    • Why is my audio not playing?
  6. See the crash

Expected behavior Get FAQs with RTL supported

Additional context Error message

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.oppia.android, PID: 14209
    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.oppia.android/org.oppia.android.app.help.faq.faqsingle.FAQSingleActivity}: java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (405 follows ‮)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (405 follows ‮)
        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:693)
        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676)
        at android.text.HtmlToSpannedConverter.convert(Html.java:774)
        at android.text.Html.fromHtml(Html.java:243)
        at androidx.core.text.HtmlCompat.fromHtml(HtmlCompat.java:163)
        at org.oppia.android.util.parser.CustomHtmlContentHandler$Companion.fromHtml(CustomHtmlContentHandler.kt:168)
        at org.oppia.android.util.parser.HtmlParser.parseOppiaHtml(HtmlParser.kt:77)
        at org.oppia.android.util.parser.HtmlParser.parseOppiaHtml$default(HtmlParser.kt:48)
        at org.oppia.android.app.help.faq.faqsingle.FAQSingleActivityPresenter.handleOnCreate(FAQSingleActivityPresenter.kt:53)
        at org.oppia.android.app.help.faq.faqsingle.FAQSingleActivity.onCreate(FAQSingleActivity.kt:20)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)

FareesHussain avatar Jan 05 '21 09:01 FareesHussain

I can take a look at this one!

KMaragh avatar Jan 11 '21 17:01 KMaragh

Taking a look at it now, and it seems like the issue happens during the closing of the custom tags, specifically the oppia-li tag.

During the handleClosingTag method in (BulletTagHandler.kt), the start and end of the BulletTag span are in the same positions, and I believe that is what is causing the issue.

Taking a look into why this could be a problem, and learning more about spans to see if maybe there is a different issue.

KMaragh avatar Jan 26 '21 20:01 KMaragh

Update: I now think the issue happens because of extra unicode characters that are present in the HTML. When the direction changes to an RTL format, there are added unicode characters to highlight the directional value of the text, in this case it seems like a lot of Pop Directional Formatting characters are added. When a custom tag is spotted, the position is marked with the (handleOpeningTag) method, to be used as the starting point for the span. However, once the rest of the text is streamed in, up until the closing of the custom tag, the marked starting point no longer refers to the beginning of a paragraph and points to one of these unicode characters.

KMaragh avatar Feb 02 '21 17:02 KMaragh

Unassigning myself as I won't me working on this.

veena14cs avatar Sep 21 '21 11:09 veena14cs

Is this still an issue? FAQ seems to work fine in a real RTL locale (Arabic).

BenHenning avatar Oct 07 '21 01:10 BenHenning

@BenHenning I tested this with psuedolocale and it doesn't work it crashes on FAQ.

veena14cs avatar Oct 07 '21 09:10 veena14cs

@veena14cs was that on latest develop? When I try with the production MR3 app it doesn't actually even go into RTL mode with the pseudolocale (which might be a change since we now have new language selection mechanisms built-in).

BenHenning avatar Oct 08 '21 00:10 BenHenning

@BenHenning @veena14cs Not able to reproduce this on google pixel emulator, please see on attached video. What Android API is this happening on. Or was fixed by some of the previously merged commits?

https://user-images.githubusercontent.com/20886444/188838406-92cc79c2-1d31-46db-adac-07d1933afdbf.mp4

KevinGitonga avatar Sep 07 '22 09:09 KevinGitonga

Thanks @KevinGitonga. Per the recent work @veena14cs and I completed in separate PRs and the nature of the error, I think it's quite likely this issue has already been resolved. The verification is helpful--marking this as closed since it seems to now be fixed.

BenHenning avatar Sep 07 '22 09:09 BenHenning