You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.
Occasionally I see heights of chat bubbles clearly wrong.
-- Typically the bubble for a single line of text is as tall as a bubble for an image, or an image is squished down to the height of a single line of text.
I suspected the CGSize cache (_messageBubbleCache) &/or cell reuse, because the incorrect size was typically when a larger bubble went offscreen because of an incoming chat message. So I investigated that angle. _messageBubbleCache uses messageItem.hash for the cache key. The demo application provides a custom implementation for -[hash], but my application uses custom classes for JSQMessageData.
I believe the problem is that my JSQMessageData does not implement hash, and therefore uses the NSObject implementation. It appears that the NSObject implementation is to return the object's pointer as the hash value. So, if one of my JSQMessageData objects representing a picture is deallocated and a single-line text is allocated at the same address, the cache will produce a false-positive hit.
This is clearly my problem with an obvious solution, but I was thinking that the JSQMessageViewController library could have helped me avoid this by making -[hash] a required method on the JSQMessageData protocol. (or define its own selector for the cache key)
What do you think about that as an enhancement request?
The text was updated successfully, but these errors were encountered:
TSAnimatedAdapter is used when rendering GIFs. TSAnimatedAdapter
inherits from JSQMediaItem but does not provide a custom implementation
of the hash method. The default implementation of hash in JSQMediaItem
results in all messages of a given interaction type (incoming,
outgoing) sharing a cached bubble size. For this reason, JSQMediaItem
subclasses are required to implement hash (see
jessesquires/JSQMessagesViewController#631).
This commit fixes issue #1275 by implementing hash in TSAnimatedAdapter
the same way TSPhotoAdapter does.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
@jessesquires
Occasionally I see heights of chat bubbles clearly wrong.
-- Typically the bubble for a single line of text is as tall as a bubble for an image, or an image is squished down to the height of a single line of text.
I suspected the CGSize cache (_messageBubbleCache) &/or cell reuse, because the incorrect size was typically when a larger bubble went offscreen because of an incoming chat message. So I investigated that angle. _messageBubbleCache uses messageItem.hash for the cache key. The demo application provides a custom implementation for -[hash], but my application uses custom classes for JSQMessageData.
I believe the problem is that my JSQMessageData does not implement hash, and therefore uses the NSObject implementation. It appears that the NSObject implementation is to return the object's pointer as the hash value. So, if one of my JSQMessageData objects representing a picture is deallocated and a single-line text is allocated at the same address, the cache will produce a false-positive hit.
This is clearly my problem with an obvious solution, but I was thinking that the JSQMessageViewController library could have helped me avoid this by making -[hash] a required method on the JSQMessageData protocol. (or define its own selector for the cache key)
What do you think about that as an enhancement request?
The text was updated successfully, but these errors were encountered: