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

Emoji fix #4698

Merged
merged 11 commits into from
Dec 13, 2021
Merged

Emoji fix #4698

merged 11 commits into from
Dec 13, 2021

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Dec 13, 2021

The main issue (#4691) is fixed, but now the app is crashing for another reason:

Thread: main, Exception: com.airbnb.epoxy.ImmutableModelException: The model was changed during the bind call. Position: 2 Model: MessageTextItem_{searchForPills=false, message=🚀, canUseTextFuture=false, useBigFont=true, previewUrlRetriever=im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever@b87961d, previewUrlCallback=RoomDetailFragment{6b98f58} (13eb1acc-4ef4-4db1-8d24-95e58efa694f id=0x7f090639), imageContentRenderer=im.vector.app.features.media.ImageContentRenderer@fe5f092, movementMethod=im.vector.app.core.utils.EvenBetterLinkMovementMethod@2861e82, attributes=Attributes(avatarSize=78, informationData=MessageInformationData(eventId=$UWClP7CkuMRG6Cm9jzbWftPf7lN0ovw5UkU8laaD2g8, [email protected]:matrix.org, sendState=SYNCED, time=12:35, ageLocalTS=1639395345987, avatarUrl=mxc://matrix.org/jRqrnjimPBqTSSdJlOupMqSx, memberName=benoit, showInformation=true, forceShowTimestamp=false, orderedReactionList=null, pollResponseAggregatedSummary=null, hasBeenEdited=false, hasPendingEdits=false, referencesInfoData=null, sentByMe=false, e2eDecoration=NONE, sendStateDecoration=NONE), avatarRenderer=im.vector.app.features.home.AvatarRenderer@af2c993, messageColorProvider=im.vector.app.features.home.room.detail.timeline.MessageColorProvider@d7ccdd0, itemLongClickListener=im.vector.app.features.home.room.detail.timeline.helper.MessageItemAttributesFactory$$ExternalSyntheticLambda0@3b931c9, itemClickListener=Function1<android.view.View, kotlin.Unit>, memberClickListener=Function1<android.view.View, kotlin.Unit>, reactionPillCallback=RoomDetailFragment{6b98f58} (13eb1acc-4ef4-4db1-8d24-95e58efa694f id=0x7f090639), avatarCallback=RoomDetailFragment{6b98f58} (13eb1acc-4ef4-4db1-8d24-95e58efa694f id=0x7f090639), readReceiptsCallback=RoomDetailFragment{6b98f58} (13eb1acc-4ef4-4db1-8d24-95e58efa694f id=0x7f090639), emojiTypeFace=android.graphics.Typeface@d9865418), highlighted=false, leftGuideline=99, dimensionConverter=null}MessageTextItem_{id=8001435373522078711, viewType=2131297544, shown=true, addedToAdapter=false}
Epoxy attribute fields on a model cannot be changed once the model is added to a controller. Check that these fields are not updated, or that the assigned objects are not mutated, outside of the buildModels method. The only exception is if the change is made inside an Interceptor callback. Consider using an interceptor if you need to change a model after it is added to the controller and before it is set on the adapter. If the model is already set on the adapter then you must call `requestModelBuild` instead to recreate all models.
    at com.airbnb.epoxy.EpoxyModel.validateStateHasNotChangedSinceAdded(EpoxyModel.java:466)
    at im.vector.app.features.home.room.detail.timeline.item.MessageTextItem_.handlePostBind(MessageTextItem_.java:59)
    at im.vector.app.features.home.room.detail.timeline.item.MessageTextItem_.handlePostBind(MessageTextItem_.java:29)
    at com.airbnb.epoxy.EpoxyViewHolder.bind(EpoxyViewHolder.java:77)

If I change this line to this:

val linkifiedBody = body // .linkify(callback)

there is no crash.

I'm still digging

EDIT Issues fixed now, thanks @ouchadam for the investigation and suggestion, and finally the review.

Fixes #4691

@bmarty bmarty marked this pull request as draft December 13, 2021 11:45
@github-actions
Copy link

github-actions bot commented Dec 13, 2021

Unit Test Results

  66 files  ±0    66 suites  ±0   55s ⏱️ -1s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit b9799b4. ± Comparison against base commit 5ea7f3c.

♻️ This comment has been updated with latest results.

@bmarty
Copy link
Member Author

bmarty commented Dec 13, 2021

I have isolated the crash, testing on another list:

        // "😮‍💨" is 😮 + Unicode Character 'ZERO WIDTH JOINER' (U+200D) + ‍💨
        userListHeaderItem {
            id("test")
            // This is fine. Set text to "😮‍💨"
            header("\uD83D\uDE2E\u200D\uD83D\uDCA8")
        }

        userListHeaderItem {
            id("test2")
            // This crashes when converting the String to a Spannable
            header("\uD83D\uDE2E\u200D\uD83D\uDCA8".toSpannable())
        }

Will try to find a workaround and report the issue to Epoxy (?)

@bmarty
Copy link
Member Author

bmarty commented Dec 13, 2021

Another way to get the crash is:

        // "😮‍💨" is 😮 + Unicode Character 'ZERO WIDTH JOINER' (U+200D) + ‍💨
        val text = "\uD83D\uDE2E\u200D\uD83D\uDCA8"
        val emoCompat = EmojiCompat.get().process(text)!!
        genericItem {
            id("testCompat")
            // Crash
            title(emoCompat)
        }

With this stack trace:

 Thread: main, Exception: com.airbnb.epoxy.ImmutableModelException: The model was changed during the bind call. Position: 0 Model: GenericItem_{title=😮‍💨, description=null, style=NORMAL_TEXT, endIconResourceId=-1, titleIconResourceId=-1, hasIndeterminateProcess=false, buttonAction=null, destructiveButtonAction=null}GenericItem_{id=-1262228796746412577, viewType=2131493164, shown=true, addedToAdapter=false}
    
    Epoxy attribute fields on a model cannot be changed once the model is added to a controller. Check that these fields are not updated, or that the assigned objects are not mutated, outside of the buildModels method. The only exception is if the change is made inside an Interceptor callback. Consider using an interceptor if you need to change a model after it is added to the controller and before it is set on the adapter. If the model is already set on the adapter then you must call `requestModelBuild` instead to recreate all models.
        at com.airbnb.epoxy.EpoxyModel.validateStateHasNotChangedSinceAdded(EpoxyModel.java:466)
        at im.vector.app.core.ui.list.GenericItem_.handlePostBind(GenericItem_.java:59)
        at im.vector.app.core.ui.list.GenericItem_.handlePostBind(GenericItem_.java:29)
        at com.airbnb.epoxy.EpoxyViewHolder.bind(EpoxyViewHolder.java:77)
     

So it seems that Epoxy does not like TypefaceEmojiSpan which inherit from ReplacementSpan:

image

@bmarty bmarty force-pushed the feature/bma/emoji_hotfix branch from c2001e2 to da1b1a5 Compare December 13, 2021 17:15
@bmarty bmarty force-pushed the feature/bma/emoji_hotfix branch from da1b1a5 to 808c401 Compare December 13, 2021 17:19
@bmarty bmarty marked this pull request as ready for review December 13, 2021 19:38
@bmarty bmarty enabled auto-merge December 13, 2021 19:39
@Flam3z
Copy link

Flam3z commented Dec 13, 2021

Thanks for working on this so quick team <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trans Flag Emoji Crashes element
3 participants