Coder Social home page Coder Social logo

Comments (4)

kaushikgopal avatar kaushikgopal commented on May 22, 2024

Hiya.

Sure let's try to break it down and get to the bottom of the issue.

The first problem you described seems like your not unsubscribing from the
observable at the end of the life cycle. Help me answer these questions:

  1. Did you pull the latest code from the repo? (I recently pushed some
    fixes)
  2. Which example specifically are you trying ? Give me the name of the
    class from the sample repo.

from rxjava-android-samples.

supervital avatar supervital commented on May 22, 2024
  1. No, I didn`t.
  2. I was trying the RetrofitFragment.

The interesting thing is that I unsubscribe on OnDestroy of that fragment. In the example the Observable was not unsubscribed, so, I created the local Subscriber, init it by button click, and unsubscribe on OnDestroy.

I have just pulled the changes and the issue still reproducing. I was debugging and the Observable is being unsubscribed.

Steps to reproduce:

  1. Turn off the internet (to simulate no internet connection exception)
  2. Open the Retrofit-RxJava example.
  3. Press the button.
  4. onError observer is called. Error logged.
  5. close the app with back button.
  6. do 2,3 steps
  7. two onError is called. 2 Error logged.

Kill the process - helps to fix the issue.
Looks like Observable holds the Activities reference, even app was closed with back button.

from rxjava-android-samples.

kaushikgopal avatar kaushikgopal commented on May 22, 2024

excellent catch! couple of points:

a. the "leak" was not being caused by any of the Rx activity. so the Retrofit + RxJava combination was not causing any of the issues. I tested this by removing all Rx related stuff from the fragment and placing a debug log statement in the onResume method. You'll notice multiple instances of the fragment being created.
b. while i cannot pinpoint and tell you exactly what went wrong, i cleaned up the fragment construction and the backstack behavior. This solved the problem. If you have a look at #a0b2e2d you'll see the differences. Essentially i remove the useless activity_main layout, and when adding fragments i use android.R.id.content instead of a custom id.

Needless to say, post cleanup, the multiple fragment instance logs didn't show up.

i'm going ahead and closing this issue. thanks for letting me know. if you're still facing issues, let me know and i'll reopen.

from rxjava-android-samples.

supervital avatar supervital commented on May 22, 2024

Yes, the issue is resolved.

Thanks for your contribution to RxJava tutorials! The examples are clear and useful! :)

from rxjava-android-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.