react-native-video-processing icon indicating copy to clipboard operation
react-native-video-processing copied to clipboard

Android native crash-- Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

Open GeoffreyPlitt opened this issue 6 years ago • 14 comments

We're seeing this on Android devices on production. One example is a Samsung SM-G930V, Android 7.0 / API 24. It happens when ProcessingManager.getPreviewForSecond() is called with a value very close to the end of the video. We suspect rounding errors or something else is causing it to try to extract a frame past the end.

Solving this bug would be nice, but even before it's solved, it should be properly trapped and raised as a JS-error, not a native Java error that crashes the whole app. Right now the crash is making this really tough for us.

We've already tried subtracting an epsilon value, and we're actually subtracting a full second and still going past the end, so this is not easy to work around.

GeoffreyPlitt avatar Aug 14 '17 18:08 GeoffreyPlitt

Sorry for late reply @GeoffreyPlitt . Can you please provide more details.

Can you please show me the Callstack ?

shahen94 avatar Aug 30 '17 09:08 shahen94

@zachrnolan

GeoffreyPlitt avatar Aug 30 '17 19:08 GeoffreyPlitt

Hi @shahen94, I work with @GeoffreyPlitt.

Here's the callstack, let me know if you need anything else.

java.lang.NullPointerException Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference 
    Trimmer.java:348 com.shahenlibrary.Trimmer.Trimmer.getPreviewImageAtPosition
    TrimmerManager.java:83 com.shahenlibrary.Trimmer.TrimmerManager.getPreviewImageAtPosition
    Method.java:-2 java.lang.reflect.Method.invoke
    JavaMethodWrapper.java:372 com.facebook.react.cxxbridge.JavaMethodWrapper.invoke
    JavaModuleWrapper.java:162 com.facebook.react.cxxbridge.JavaModuleWrapper.invoke
    NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
    Handler.java:751 android.os.Handler.handleCallback
    Handler.java:95 android.os.Handler.dispatchMessage
    MessageQueueThreadHandler.java:31 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
    Looper.java:154 android.os.Looper.loop
    MessageQueueThreadImpl.java:199 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
    Thread.java:761 java.lang.Thread.run

zachrnolan avatar Aug 30 '17 20:08 zachrnolan

@zachrnolan @GeoffreyPlitt Thanks guys! And how much is the length of your video file ?

shahen94 avatar Aug 31 '17 05:08 shahen94

@shahen94 it seems to be happening at any length.

zachrnolan avatar Aug 31 '17 17:08 zachrnolan

+1

huowenxuan avatar Sep 13 '17 03:09 huowenxuan

@shahen94 hey, just wanted to check in and see if you were able to find anything. Thanks!

zachrnolan avatar Sep 18 '17 21:09 zachrnolan

Hi @zachrnolan . Unfortunately no - @gevorg94 can you please take a look at this issue ? Might you can help

shahen94 avatar Sep 20 '17 10:09 shahen94

Hey @shahen94 @gevorg94 friendly ping to see if you guys were able to look at this yet. Thanks!

zachrnolan avatar Nov 03 '17 16:11 zachrnolan

Any update on this issue? I'm seeing the same crash in production as well.

gvillenave avatar Jan 22 '18 20:01 gvillenave

Guys, I'm not sure why this is happening. This could happen only when you're trying to get preview image for a second which is greater than the length of Video.

To have a temporary solution, you could add check in this line.

https://github.com/shahen94/react-native-video-processing/blob/master/android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java#L527

if (bmp == null) {
  return;
}

shahen94 avatar Jan 23 '18 07:01 shahen94

I'm having the same problem here. Have anyone find a solution?

maxhalty avatar Mar 06 '18 14:03 maxhalty

Facing the same issue here on some Android devices (just happened on Google Pixel running Android version 8.1.0).

jln-dk avatar Apr 08 '18 08:04 jln-dk

I also stuck here please help.

RONAKDHOLARIYA avatar Jul 27 '19 05:07 RONAKDHOLARIYA