React-native: BlobModule supports invokes virtual method String.equals() on null

Created on 5 Apr 2018  路  11Comments  路  Source: facebook/react-native


app breaks after upgrading to RN-0.54 due to exception in native call.

Environment


Environment:
OS: macOS High Sierra 10.13.4
Node: 9.7.1
Yarn: 1.3.2
npm: 5.8.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.1 AI-173.4670197

Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
react-native: 0.54.2 => 0.54.2

Steps to Reproduce

  • upgrade to RN 0.54
  • debug in release mode on Android

Expected Behavior


the app should not break

Actual Behavior

04-05 06:43:35.824 20182-20198/com.science.ure E/Surface: getSlotFromBufferLocked: unknown buffer: 0xea08c500
04-05 06:43:37.388 20182-20211/com.science.ure E/unknown:ReactNative: Exception in native call
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
        at com.facebook.react.modules.blob.BlobModule$2.supports(BlobModule.java:83)
        at com.facebook.react.modules.network.NetworkingModule.sendRequest(NetworkingModule.java:257)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
        at android.os.Looper.loop(Looper.java:148)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
        at java.lang.Thread.run(Thread.java:818)

image

the line of code that break in BlobModule is:

        boolean isRemote = scheme.equals("http") || scheme.equals("https");

looks like it did not successfully get the scheme, which should be returned by getScheme() from NetworkingModule.

Potential solution:
Add null-checking on scheme? #

Android Locked

Most helpful comment

Even using the fix, the problem persists here. Anyone else?

All 11 comments

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

An easy fix would be just to replace that line with

boolean isRemote = "http".equals(scheme) || "https".equals(scheme);

@shockdesign thanks for your reply! :D I found what is causing this error.
I simply set a break point on this line and i found that react-native-svg-uri is passing local svg file as a uri, so this function getScheme() in the NetworkingModule.java returns null and breaks "http".equals(scheme).

has this been fixed now?

@Brian-Azizi - no, not fixed. Current master still has the same issue. Original poster found a workaround for his specific instance of the problem and therefore closed it, but the problem still persists for the rest of us...

Hi guys. Try to open Android studio and set a break point at this line and see where this 'null' comes from. Then you can go back to your react native code to fix it.

I, for example, bump into this while calling /graphql endpoint through non-native library (apollo-client).

Submitted the fix ^^

Even using the fix, the problem persists here. Anyone else?

same issue :(

Same here.

Was this page helpful?
0 / 5 - 0 ratings