我試圖在的onDraw方法,使用機器人Movie類如下顯示在ImageView的GIF動畫:的Android:致命信號11在00000000(SIGSEGV)(代碼= 1)上movie.draw
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.TRANSPARENT);
super.onDraw(canvas);
long now = android.os.SystemClock.uptimeMillis();
if (movieStart == 0) {
movieStart = now;
}
movie = getMovieFromGif();
if (movie != null && movie.duration() > 0) {
try {
int relTime = (int) ((now - movieStart) % movie.duration());
movie.setTime(relTime);
float movie_height = convertDpToPixels(movie.height());
float movie_width = convertDpToPixels(movie.width());
float new_movie_height = movie_height;
float new_movie_width = movie_width;
float movie_ratio = movie_width/movie_height;
if (new_movie_width > container_width) {
new_movie_width = container_width;
new_movie_height = new_movie_width/movie_ratio;
}
if (new_movie_height > container_height) {
new_movie_height = container_height;
new_movie_width = new_movie_height * movie_ratio;
}
float scale_x = container_width/new_movie_width;
float scale_y = container_height/new_movie_height;
scale_x = new_movie_width/(float) movie.width();
scale_y = new_movie_height/(float) movie.height();
canvas.scale(scale_x, scale_y);
float x = 0;
if ((float) this.getWidth() > new_movie_width) {
x = ((this.getWidth() - (movie.width() * scale_x))/2f)
/scale_x;
}
movie.draw(canvas, x, 0);
this.invalidate();
} catch (Exception ex) {
Log.i("onDraw()", "Error: " + ex.getMessage());
}
}
}
代碼運行在大多數設備,但對華爲登高P7和三星galaxy a5中,上movie.draw應用程序崩潰(畫布中,x,0)與異常細:
A/libc的(23632):致命信號11( SIGSEGV)在0x00000000(代碼= 1), 線程23632
任何想法movie.draw在這些設備上有什麼問題?
更新: 下面是完整的堆棧跟蹤
致命信號11(SIGSEGV):A/libc的(18951)12月4日至29日:09:24.979:d /活動(18951):#2 setTransGradationModeColor 爲true
12月4日至29日:09:25.049 :I/Adreno-EGL(18951): :EGL 1.4 QUALCOMM構建:()
04-29 12:09:25.049:I/Adreno-EGL(18951):OpenGL ES着色器編譯器版本: E031.24.02。 07
04-29 12:09:25.049:I/Adreno-EGL(18951):Build Date:08/06/14 Wed
04-29 12:09:25.049:I/Adreno-EGL(18951):Local Branch:rb1
04-29 12:09:25.049:I/Adreno-EGL(18951):Remote Branch:
04-29 12:09:25.049:I/Adreno-EGL(18951):Local Patches:
04-29 12:09:25.049:I/Adreno-EGL(18951):重建分支:
04-29 12:09:25.079:D/OpenGLRenderer(18951):啓用調試模式 04-29 12 :09:25.109:D/skia(18951):streamToByte:輸入agif 圖片大於30MB。
04-29 12:09:25.109 D/skia(18951): D/skia(18951):媚眼AGIF移動構建器結束9 ,TOTALTIME:2700
12月4日至29日:09:25.109:在 00000000(代碼= 1),螺紋18951(com.android.gif)
執行代碼movie.draw()後發生致命信號錯誤,rest是movie.draw()之前的行執行的堆棧跟蹤。
這似乎是一個本地空指針去引用,但您需要發佈完整的本機堆棧跟蹤以解開它,而不僅僅是一行的一部分。 –
用堆棧跟蹤更新了問題。 –
這不是一個堆棧跟蹤,而是緊挨在堆棧跟蹤之前的一些日誌消息。也包括實際的堆棧跟蹤。 –