shahen94 / react-native-video-processing

Native Video editing/trimming/compressing :movie_camera: library for React-Native
https://shahen94.github.io/react-native-video-processing/
MIT License
1.25k stars 325 forks source link

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

Open GeoffreyPlitt opened 7 years ago

GeoffreyPlitt commented 7 years ago

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.

shahen94 commented 7 years ago

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

Can you please show me the Callstack ?

GeoffreyPlitt commented 7 years ago

@zachrnolan

zachrnolan commented 7 years ago

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
shahen94 commented 7 years ago

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

zachrnolan commented 7 years ago

@shahen94 it seems to be happening at any length.

huowenxuan commented 6 years ago

+1

zachrnolan commented 6 years ago

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

shahen94 commented 6 years ago

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

zachrnolan commented 6 years ago

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

gvillenave commented 6 years ago

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

shahen94 commented 6 years ago

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;
}
maxhalty commented 6 years ago

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

jln-dk commented 6 years ago

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

RONAKDHOLARIYA commented 5 years ago

I also stuck here please help.