Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instabug overrides default RxJava error handler #126

Closed
linean opened this issue Sep 28, 2018 · 33 comments
Closed

Instabug overrides default RxJava error handler #126

linean opened this issue Sep 28, 2018 · 33 comments
Assignees

Comments

@linean
Copy link

linean commented Sep 28, 2018

Instabug automatically overrides RxJava error handler by calling RxJavaPlugins.setErrorHandler() in initialization. Because of that OnErrorNotImplementedException is not throwed anymore and there are no logs in console.

Steps to Reproduce the Problem

Run this code anywhere in the app:
Completable.fromAction(()-> { throw new RuntimeException(); }).subscribe();

Expected Behavior

App should throw:

io.reactivex.exceptions.OnErrorNotImplementedException

Actual Behavior

Nothing happens - no logs in console

Instabug integration code

Instabug.Builder(application, "my_token") .setInvocationEvents(InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT, InstabugInvocationEvent.SHAKE) .setReproStepsState(State.ENABLED) .setViewHierarchyState(Feature.State.ENABLED) .build()

SDK Version

8.0.7

Android Version

Any

Device Model

Any

[Optional] Project That Reproduces the Issue

@Korazy Korazy self-assigned this Oct 1, 2018
@Korazy
Copy link

Korazy commented Oct 1, 2018

Hey @linean

Thanks for reaching out. We will look into this and get back to you as soon as possible.

@jdamcd
Copy link

jdamcd commented Oct 8, 2018

I'm also seeing this in 8.0.9. The Instabug error handler set on RxJavaPlugins is not forwarding exceptions to the thread's uncaught exception handler, so exceptions thrown in e.g. onSuccess() callbacks are swallowed silently when they should terminate the app.

@Korazy
Copy link

Korazy commented Oct 10, 2018

Hey all,

Can you try to add a CompletableObserver() for the subscription you made and you should be getting the error in onError callback, like this:

Completable.fromAction(new Action() {
         @Override
         public void run() throws Exception {
             throw new IllegalAccessException("Throwable String");
         }

     }).subscribe(new CompletableObserver() {
         @Override
         public void onSubscribe(Disposable d) { }

         @Override
         public void onComplete() { }

         @Override
         public void onError(Throwable e) {
              // Get the throwable here 
         }
     });

@ablenesi
Copy link

We have the same issue on 8.0.9. Just spent a couple hours on figuring out why all our network call subscriptions are never reached.
java.lang.NoSuchMethodError: No virtual method setHeaders(Ljava/lang/String;)V in class Lcom/instabug/library/model/NetworkLog; or its super classes (declaration of 'com.instabug.library.model.NetworkLog' appears in /data/app/com.***.debug-GLEsaFJhkPv89M_FxiUEuA==/base.apk!classes5.dex)
This issue might be related to #123

@linean
Copy link
Author

linean commented Oct 10, 2018

@Korazy it works like this. But this is expected, because observer handles error by itself, and RxJavaPlugins.onError is not called.

@jdamcd
Copy link

jdamcd commented Oct 10, 2018

As a workaround, it's possible to clear the error handler after initialising Instabug: RxJavaPlugins.setErrorHandler(null). Surprised to see this being set, especially since we're not using the crash reporting feature.

@linean
Copy link
Author

linean commented Oct 10, 2018

And even better is to first get current handler :)

val errorHandler = RxJavaPlugins.getErrorHandler()
initializeInstabug()
RxJavaPlugins.setErrorHandler(errorHandler)

@Korazy
Copy link

Korazy commented Oct 11, 2018

We currently have a fix that's pending review and testing at the moment. I will make sure to update you soon :)

@Korazy
Copy link

Korazy commented Oct 15, 2018

Hey all, can you please use this snapshot and let me know if it fixes the issue for you?

Snapshot version: 8.0.11.4-SNAPSHOT (must set compileSdkVersion to 28)
Instructions on adding snapshot: Add the following code

repositories {
    maven {
        // TODO add this only if interested in getting SNAPSHOT releases
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}

@Korazy
Copy link

Korazy commented Oct 22, 2018

Hey all, did the snapshot fix the issue for you?

@jdamcd
Copy link

jdamcd commented Oct 23, 2018

Hi @Korazy. We've noticed a related issue. The Instabug SDK (8.0.9) is setting a default exception handler, even though we're configuring the SDK with setCrashReportingState(Feature.State.DISABLED). This was overriding our expected error handling and masking further crashes. Is this issue also resolved in the snapshot?

@Korazy
Copy link

Korazy commented Oct 24, 2018

Hey @jdamcd

Would you be able to explain the issue further?

@linean
Copy link
Author

linean commented Oct 24, 2018

@jdamcd this is exact same thing that I've described :)

@jdamcd
Copy link

jdamcd commented Oct 24, 2018

Sure. We've observed an issue with Thread.setDefaultUncaughtExceptionHandler() being set in addition to RxJavaPlugins.setErrorHandler() which @linean described. It's unexpected because we're not using Instabug for crash reporting.

@ramiimagdi
Copy link

Hey all,

Apologies for taking some time on this, I just want to let you know that the issue is still being investigated, and we'll be reaching out to you as soon as we get a hand on it.

Thank you for your patience.

@Korazy
Copy link

Korazy commented Nov 2, 2018

Hey all,

While we do indeed set our handlers, we do forward the uncaught exception so that it goes to its usual follow-up and this shouldn't affect anything in this regard. We also don't really fail silently or prevent apps from crashing. Does that make sense?

@linean
Copy link
Author

linean commented Nov 20, 2018

What about if someone is using custom exceptions handler, will Instabug overrides it silently? And sorry for asking, but I'm lost, what is the status of this issue?

@jdamcd
Copy link

jdamcd commented Nov 20, 2018

@Korazy Here's a sample project to demonstrate that initialising the Instabug SDK alters RxJava behaviour: https://github.com/jdamcd/instabug-rx-issue

@Korazy
Copy link

Korazy commented Nov 21, 2018

Out of curiousity, did the snapshot I sent before not fix the issue for you?

@jdamcd
Copy link

jdamcd commented Nov 21, 2018

It fixes the core issue since no RxJavaPlugins error handler is set. However, the SDK then crashes internally from system onLowMemory() callbacks. Reproduction steps in the sample project: jdamcd/instabug-rx-issue#1

@linean
Copy link
Author

linean commented Nov 21, 2018

@Korazy 8.0.11.4-SNAPSHOT works for me :)

@Korazy
Copy link

Korazy commented Nov 21, 2018

@linean awesome!

@jdamcd we’ll look into that right away.

@Korazy
Copy link

Korazy commented Nov 22, 2018

@jdamcd would you be able to try this snapshot? 8.0.11.19-SNAPSHOT

@jdamcd
Copy link

jdamcd commented Nov 22, 2018

@Korazy 8.0.11.19-SNAPSHOT resolves both issues. Thanks for your help! 🎉

@Korazy
Copy link

Korazy commented Nov 25, 2018

Awesome! Glad everything is working out now 😄

@Korazy Korazy closed this as completed Nov 25, 2018
@jdamcd
Copy link

jdamcd commented Nov 30, 2018

Hey @Korazy, could you update here when those fixes make it into a stable build? Looks like 8.0.12 & 8.0.13 from last week still have the issues. Thanks!

@Karambar
Copy link

Hi @Korazy ,

I encounter the same issue, could we have an update ?
Will it be available soon on the stable build ?
I added a fix on my side but I should not have to do this hack.

Thanks for your help !

@vayan
Copy link

vayan commented Dec 12, 2018

Hello 👋

Same here, when is the next stable build with this fix? Cheers!

@jdamcd
Copy link

jdamcd commented Jan 14, 2019

Any news on when this fix will be included in a stable release @Korazy?

@Axrorxoja
Copy link

Axrorxoja commented Mar 15, 2019

I have same issue in in 8.1.2 version
java.lang.NoSuchMethodError: No virtual method setHeaders(Ljava/lang/String;)V in class Lcom/instabug/library/model/NetworkLog; or its super classes (declaration of 'com.instabug.library.model.NetworkLog' appears in /data/app/android-XXXJAfLGgWcyo1G0xvz6vg==/split_lib_slice_0_apk.apk!classes2.dex) at com.instabug.library.okhttplogger.InstabugOkhttpInterceptor.intercept(InstabugOkhttpInterceptor.java:128) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

@mzelzoghbi
Copy link
Contributor

Hi @Axrorxoja , Thanks for reporting this. We think that this issue is not related to the one mentioned in the thread from the beginning. Can you double check it? Also, You should be sure that you are using the latest version of instabug-with-okhttp-interceptor which is 8.1.2.

@Axrorxoja
Copy link

Hi @mzelzoghbi thank you for feedback

@mzelzoghbi
Copy link
Contributor

Awesome! Glad everything is working out now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants