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

特定のapngをリアクションを表示することができない #461

Open
pantasystem opened this issue Mar 8, 2022 · 8 comments

Comments

@pantasystem
Copy link
Owner

以下のヘッダーを表示できない
89504E47

@pantasystem
Copy link
Owner Author

java.lang.IllegalArgumentException: Bad position 1127835099/11998
        at java.nio.Buffer.position(Buffer.java:259)
        at java.nio.ByteBuffer.position(ByteBuffer.java:812)
        at com.github.penfeizhou.animation.io.ByteBufferReader.skip(ByteBufferReader.java:24)
        at com.github.penfeizhou.animation.io.FilterReader.skip(FilterReader.java:20)
        at com.github.penfeizhou.animation.apng.decode.Chunk.parse(Chunk.java:42)
        at com.github.penfeizhou.animation.apng.decode.APNGParser.parseChunk(APNGParser.java:136)
        at com.github.penfeizhou.animation.apng.decode.APNGParser.parse(APNGParser.java:108)
        at com.github.penfeizhou.animation.apng.decode.APNGDecoder.read(APNGDecoder.java:78)
        at com.github.penfeizhou.animation.apng.decode.APNGDecoder.read(APNGDecoder.java:27)
        at com.github.penfeizhou.animation.decode.FrameSeqDecoder$5.run(FrameSeqDecoder.java:226)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)

ライブラリの不具合の可能性が高い

@pantasystem
Copy link
Owner Author

関連
#976

@pantasystem
Copy link
Owner Author

:loading:などのカスタム絵文字を表示することができない

@samunohito
Copy link
Contributor

samunohito commented Oct 26, 2023

何が起こってるのか調べてみました。

Bad position 1127835099/11998

上記を見て、想定外の値をAPNGのサイズ情報として読み取っている可能性があると考えました。
そこで、ライブラリにブレークポイントをはり、1127835099同様に想定外の数値をサイズ情報として読み取るまでアプリを動かしてみたところ、この現象が発生する画像側に問題があることがわかりました。

どこがおかしいかを分かりやすくするため、正常に表示できているAPNGと表示できていないAPNG(今回は:loading:)を比較してみました。

:ablob_fox_loading:(※)
image

:loading:
image

※こういうAPNGです。橙色の輪郭の中で黒い記号が回転しています
image

正常に表示できているablob_fox_loadingはIENDチャンクでバイナリが終わっているのに対し、loadingはIENDチャンク以降にもバイナリが存在しています(IENDチャンクを選択して反転表示しています)。
ライブラリがこの余剰なバイトを読み込み、画像の要領である11998を大きく超える1127835099にアクセスしようとして本件の現象が発生しているようです。

参考:
https://qiita.com/spc_ehara/items/c748ec636283df805926#iend%E3%83%81%E3%83%A3%E3%83%B3%E3%82%AF-1

@samunohito
Copy link
Contributor

あと、ライブラリの2.23.0と2.24.0のソースを落としてdiffをとってみましたが、明確に怪しいと思われる差分はありませんでした…

@pantasystem
Copy link
Owner Author

おー!!助かります
この辺はあまり知識がなくてどうすれば良いものかと見当すらついていなかったので
とてもありがとたいです🙇🙇🙇

@samunohito
Copy link
Contributor

samunohito commented Oct 27, 2023

たびたび失礼します。2点ほど…

  • developの最新(2.23.0を使っているバージョン)でもloadingが表示されず、ログにBad position ... のエラーが出ていました
  • 直し切る自信が無かったのでアサインのお願いをしなかったのですが、IENDチャンクより後ろは捨てるようにしたところloadingの表示が出来ました。ただし、アニメーションしません。
    以下の制限事項がありますが、それでもよろしければプルリクエストを発行しようと考えています。
    如何でしょうか…(要否問わず遠慮なくお申し付けください)
    • 上記に記載の通りアニメーションしない(原因不明で直しきれず…)
    • 画像の末尾よりIENDチャンクを線形探索しているため、わずかにパフォーマンスが落ちることが予想される

@pantasystem
Copy link
Owner Author

原因の究明からPRまで本当に助かります🙏🏻🙏🏻
アサインいたしましたよろしくお願いします🙇🙇🙇

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

No branches or pull requests

2 participants