Glide版本3.7 目前不清楚4及以上版本是否有同样的问题
今天使用glide播放gif发现播放的速度很慢,在ios或者其他地方都没有这种问题。
跟踪源码查找发现,与播放速度相关的是每一帧的延时时间:
private void loadNextFrame() {
if (!isRunning || isLoadPending) {
return;
}
isLoadPending = true;
gifDecoder.advance();
long targetTime = SystemClock.uptimeMillis() + gifDecoder.getNextDelay();//获取一帧的延时时间
DelayTarget next = new DelayTarget(handler, gifDecoder.getCurrentFrameIndex(), targetTime);
requestBuilder
.signature(new FrameSignature())
.into(next);
}
public int getDelay(int n) {
int delay = -1;
if ((n >= 0) && (n < header.frameCount)) {
delay = header.frames.get(n).delay;//从解析出的gifheader中获取此帧延时时间
}
return delay;
}
而在解析gif的过程中:
int delayInHundredthsOfASecond = readShort();
// TODO: consider allowing -

在使用Glide v3.7加载Gif时遇到播放速度慢的问题,原因是Glide将小于30毫秒的帧延迟设为了100毫秒。通过反射修改GifDecoder以优化播放速度,但这不是一个灵活的解决方案。期待更好的解决策略。
最低0.47元/天 解锁文章
2261

被折叠的 条评论
为什么被折叠?



