Comments (3)
I think you've found a bug in Stetho in the same way Stetho's found a bug in your code :)
The issue here is that due to the design of our JSON-RPC/WebSocket implementation, we require that all objects sent over the wire are first constructed as POJOs. The DevTools protocol requires that we read network response bodies as a single, typically base64-encoded, UTF-8 string. This means that in practice if the response body is a very large binary blob, the resulting base64 UTF-8 string will be so large that the VM will be unable to allocate it as a single contiguous char[] buffer*.
I suspect that rather than truly running out of memory, instead Dalvik/ART are refusing to allocate such a large buffer. Somewhere in Logcat output this would be reflected, though it can be hard to spot sometimes.
This can be addressed by us in a couple of ways, but the more important question is: why are you downloading images that are likely much larger than the viewport size of the device? Doing so wastes bandwidth and processing power locally, even with BitmapFactory
downsampling the image during decoding.
- - Two important details conspire to inflate the size of this allocation: 1) char is 2 bytes in Java, and 2) base64 encoding typically increases data size by ~25%. So, if your image was 1MB, you should expect an allocation of 2.5MB.
from stetho.
You're right, plugged in a Nexus 5 and I managed to find the culprit (with Stetho :) ).
I already proposed something like thumbor to reduce the image size as requested but currently it has low priority.
Just crashing like this isn't very clear tho, maybe something like logging an error if the content lenght is over a certain value (1MB should be good enough), without actually downloading it?
from stetho.
Agreed Stetho has the wrong behaviour. It's supposed to help you debug these kinds of issues, not crash :)
I think we have two decent options:
- Try to read the string, catch
OutOfMemoryException
and replace the contents with an error indicating this in some fashion. - Build a streaming API for our JSON-RPC encoder so that we can express potentially very large requests and responses (we have a couple other interesting places) in a streaming fashion for efficiency reasons. I do really like this option, but unfortunately we hacked our way through a custom WebSocket and JSON-RPC implementation and neither are exactly well suited for this at the moment.
I'm inclined to post a quick diff for 1, then take a deeper look after 1.1.0 to see if we can rearchitect and improve our underlying protocol implementation.
from stetho.
Related Issues (20)
- A potential null pointer dereference bug. Please confirm, much appreicated! HOT 1
- Database Inspection Loading Blank Page HOT 1
- dumpapp commands are failing when more than 1 device is connected HOT 2
- 看不见包名 HOT 1
- Unreleased Resource: Streams
- Double-Checked Locking
- it seems Facebook is collecting device data even it is initialised in debug mode
- Stetho protobufs - Documentation request HOT 1
- How to user Discover network targets mode inspect app
- DevTools inspect window doesn't render properly HOT 52
- Windows cannot be displayed after chrome update HOT 10
- github says version 1.6.0 is released but I couldn't find it HOT 3
- How fix this? HOT 5
- Chrome debugging not showing network api responce
- Stetho doesn't capture network in network inspector HOT 2
- Feature request to view datastore data
- NoSuchMethodError issue
- Usage of weak crypto algorithms like SHA-1 in Stetho HOT 1
- Inspect Devices UI is distorted HOT 3
- Question: How does Stetho Draw OkHttp Requests in Network Tab? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stetho.