的Android:致命信号11在00000000(SIGSEGV)(代码= 1)上movie.draw

问题描述:

我试图在的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在这些设备上有什么问题?

更新: 下面是完整的堆栈跟踪

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)

致命信号11(SIGSEGV):A/libc的(18951)

执行代码movie.draw()后发生致命信号错误,rest是movie.draw()之前的行执行的堆栈跟踪。

+0

这似乎是一个本地空指针去引用,但您需要发布完整的本机堆栈跟踪以解开它,而不仅仅是一行的一部分。 –

+0

用堆栈跟踪更新了问题。 –

+0

这不是一个堆栈跟踪,而是紧挨在堆栈跟踪之前的一些日志消息。也包括实际的堆栈跟踪。 –

我能够通过禁用Android的硬件加速来解决该问题:

安卓硬件加速=“假”

+0

任何其他解决方案? –

+0

为我工作,但不是一个可行的解决方案,因为现在每个动画都落后了 –

+0

你们是否找到了解决方案?如果禁用hardwardeAcceleration,我也面临动画滞后问题。 – AndreiBogdan

这是一样什么Sultana,但令人惊讶这里的没有为这件事工作。它是here 您仅在此特定视图上使用此线条绘制电影时禁用硬件加速器。

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);