当前位置: 动力学知识库 > 问答 > 编程问答 >

android - SurfaceView UpdateWindow() - NullpointerException

问题描述:

I have a custom video player which uses SurfaceView inside a fragment.

/* Notify SDK on Surface Creation */

public void surfaceCreated(SurfaceHolder surfaceholder) {

if(null==m_strVideoPath)

return;

LogUtil.e(TAG, "initiating player now..");

initPlayer(m_strVideoPath);

playVideo(m_strVideoPath);

}

I see lot crashes in store with a nullpointer exception in SurfaceView updateWindow method. Here are the crash logs:

java.lang.NullPointerException

at android.view.SurfaceView.updateWindow(SurfaceView.java:603)

at android.view.SurfaceView.access$000(SurfaceView.java:86)

at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)

at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)

at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1909)

at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1038)

at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5651)

at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)

at android.view.Choreographer.doCallbacks(Choreographer.java:574)

at android.view.Choreographer.doFrame(Choreographer.java:544)

at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)

at android.os.Handler.handleCallback(Handler.java:733)

at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:136)

at android.app.ActivityThread.main(ActivityThread.java:5034)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)

at dalvik.system.NativeStart.main(Native Method)

Looking into source code of SurfaceView class at 603 line gives me:

if (redrawNeeded) {

602 if (DEBUG) Log.i(TAG, "finishedDrawing");

603 mSession.finishDrawing(mWindow);

604 }

I couldn't reproduce this crash on any of my test devices, wondering if someone could help in understanding this scenario.

Thanks in advance.

分享给朋友:
您可能感兴趣的文章:
随机阅读: