Comments (9)
I can't get when it happends and it happends rarely. It seems to be randomly, but could happen when I open poups that not are on the map but is placed on top of it. These ones also get some data.
Sometimes it just crashes when I have it open. It feels like the views has been garbage collected or something. I have a lot of markers on my map, at least 100. And some objects that are moving on it.
from tileview.
Done some more digging.
I think the problem is when I remove a marker. My theory is that onMeasure in TranslationLayout is running and the view is removed while it is running measureChildren and then it have a discapency between mChildrenCount and the actual number of children (see http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/android/view/ViewGroup.java#ViewGroup.measureChildren%28int%2Cint%29).
Possible? I'm gonna look deeper into it tomorrow.
from tileview.
Hm... Of course I can't tell without seeing the code and debugging myself, but I'd be surprised if that were the issue. Almost all overridden onLayout/onMeasure methods I've seen do the same basic loop. Should be easy to tell, though - just wrap it in a try/catch or add a null check:
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
if (child == null) continue;
...
or
for (int i = 0; i < count; i++) {
try {
View child = getChildAt(i);
...
Or maybe test the count in the evaluation expression, so instead of:
int count = getChildCount();
for (int i = 0; i < count; i++) {
You could try
for (int i = 0; i < getChildCount(); i++) {
I'd be interested to hear what you discover.
from tileview.
Yeah, I feel the same way. It feels a bit strange that there could be a syncronization problem there. Just a note, it mostly happends in:
TranslationLayout.java - onMeasure:
measureChildren(widthMeasureSpec, heightMeasureSpec);
ViewGroup.java
protected void measureChildren(int widthMeasureSpec, int heightMeasureSpec) {
final int size = mChildrenCount; // This one could be out of sync
final View[] children = mChildren;
for (int i = 0; i < size; ++i) {
final View child = children[i]; // This probably returns null
if ((child.mViewFlags & VISIBILITY_MASK) != GONE) {
measureChild(child, widthMeasureSpec, heightMeasureSpec);
}
}
}
I'm gonna do some testing now!
from tileview.
I'm not any closer.
I catch the NPE with a try around all code in onMeasure but then it fails in onLayout :/ And the state of the NPE didn't give me that much.. But I'm gonna try to write out the index of the child that is null.
Unfortunately I can't reproduce the error so it is really hard debugging.
New day tomorrow... Any ideas?
And I'm thinking, I have 150+ children. Does it not take relatively long time to loop them and couldn't one get removed and cause that nullpointer.. ? Feels unlikeley but a possability..
Thanks.
from tileview.
If wrapping onMeasure with try/catch pushed the NPE off to onLayout, it sounds like you're on the right track at least. I'd try those simple tricks above in both, and see what happens.
That said - notice that your stack trace shows the error on line 46 - line 46 is the call to measureChildren
, which makes me think the NPE is not in the loop directly...
Regarding this:
And I'm thinking, I have 150+ children. Does it not take relatively long time to loop them and couldn't one get removed and cause that nullpointer.. ? Feels unlikeley but a possability..
I don't think so. I'm not 100% sure, but AFAIK, that could only happen if the two actions (onMeasure, and removal) happened in different threads.
To clarify: the NPE only happens when you remove markers?
from tileview.
I am actually not sure when it happends. It was my theory that it happened when I removed a marker.
I havn't yet found a way to trigger the error. That's the key. Will try removing add adding a lot tomorrow.
No, normally it is not direct in the loop. It is in the ViewGroup.java method measureChildren
but if it passes that (for example with try catch) it causes the error in the loop.
I'm still confused how a child can be null...
from tileview.
post back if i can help
from tileview.
@tekblom did you get this worked out? or should i leave this issue open?
from tileview.
Related Issues (20)
- Issues scaling past 1f HOT 3
- Remote tile demo freezes and crashes HOT 2
- Combine smooth scroll and scale HOT 2
- Tiles not properly laid out when Scale < 1 with remote tiles HOT 15
- Open source but no license? HOT 2
- Markers disappear when zooming HOT 4
- Cannot add tile images on the fly HOT 1
- StreamProvider asked to provide data for rows and columns out of bounds with to small images HOT 5
- Tiles outside the image are created HOT 8
- White text on white background in Advanved Tile Demo HOT 1
- Get touched position when touch on the tileview (version 4.0.7)
- longtouch
- App killed in background crashes when returning to foreground HOT 1
- `android.os.BadParcelableException` regarding `com.moagrius.widget.ScrollView$SavedState.<init>` HOT 1
- Use in viewholder for recycler view. HOT 2
- build() method starts to return void instead of TileView HOT 1
- Mike passed away HOT 5
- Does this lib support SVG format
- JCenter -> MavenCenter
- implementation 'com.qozix:tileview:2.7.7' doesn't seem to work 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 tileview.