Git Product home page Git Product logo

Comments (4)

alexchau-google avatar alexchau-google commented on May 2, 2024

master...alexchau-google:patch-1

from volley.

jpd236 avatar jpd236 commented on May 2, 2024

Serializable is generally not a wise idea on Android. It's slow and generates a ton of garbage:

https://stackoverflow.com/questions/3611843/is-using-serializable-in-android-bad

Making it Parcelable might be reasonable, but I'd need to think through whether that might have bad implications on potential existing subclasses of NetworkResponse, which is not final.

I would suggest just making your own Parcelable helper classes as you see fit in the meantime.

from volley.

alexchau-google avatar alexchau-google commented on May 2, 2024

Got it. Parcelable also works, our only use case is for passing around as part of Intent.

from volley.

jpd236 avatar jpd236 commented on May 2, 2024

On reflection, I think it would be best to avoid doing this in NetworkResponse itself. While in general Volley is intended to be used for small response bodies, NetworkResponse data can be somewhat large given that it contains the entire response body as a byte array and the list of all response header keys/values.

Binder is intended for transmission of very small values; it will crash your app if you try to send anything larger than even 1 MB over it (and that limit is shared over a whole process so the effective limit can be even less than this). This kind of crashing can be a bit tricky, e.g. you might be able to pass the data in an Intent and have it work, but then crash when you rotate the screen which triggers a parcel/unparcel pass.

While it can be reasonable to send this data directly if you know your requests/responses are small, I don't think we should make it easy to do that in Volley without thinking through these ramifications. Instead, I think it should be up to client apps to decide carefully what they should/shouldn't send over the parcel boundary by extracting needed information out of the NetworkResponse and only sending that. Ideally only the specific info that needs to be transferred over binder can be, or if larger transfers are needed then a more scalable approach like a ContentProvider should be used.

from volley.

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.