-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ArrayIndexOutOfBoundsException: rowIndex is less than 0 #2408
Comments
It looks like you are trying to change the value of a non-existing object. The object you are changing is found in a |
I am executing query findfirst() in async transaction and calling notifyDataSetChanged in recyclerView |
+1 |
@Sutirth Can you set a breakpoint at |
@beeender It happens sometime or the other not a frequent breakdown. Though I have debugged this issue for long hours and after doing everything it crashes here AllGoalsDB unsubscribeGoalResult = realm.where(AllGoalsDB.class)
.equalTo(WorkoutCashConstants.COLUMN_GOALID, allGoalsResults.get(getAdapterPosition()).getGoalID())
.findFirst(); So I have made few observation and this would be according to my theory please correct me if I am wrong. Suppose I say a user is on 2g network and for example he click subscribe(This is the time when I hit my api call and onSuccess I change the status in my realm database). And suppose there is a brief lag period and I click on subscribe again it crashes because its status is already changed in the database and hence I get row Index as 0. Would request you to keep this issue open Because I am debugging this issue continuously P.S I live in India and hence we do a rigorous testing on spectrum. |
The changes in another thread will reflect to the current thread's Realm instance in the "next" event loop. So if you are tracking some Realm data status, like the |
@beeender Exactly I am doing the same thing say for e.g if I am doing some changes in Recycler view I notify the adapter when its successful but this still I am end getting error. |
This issue is reported by VCNC too. See its CrashLytics too: http://crashes.to/s/957c6014d94 |
@beeender Closed Already without solution?? :( |
Oppos, I thought this is solved. Since we cannot reproduce this from our side can you please reproduce this issue will a minimal Android Studio project and share with us so we can do some investigation on it? to help@realm.io |
has the same issue occurred some times, when the the adapter being updated and the user click before or while the adapter is being updated, try {
list.get(getAdapterPosition());
} catch (Exception ignored) {
return;
} |
I have the same issue, but it may be because I remove data from Realm in another thread. Do all the transactions in the same thread is not possible for me. Any suggestion? |
@KynoYang Can you share some related code with us? to help@realm.io if you want to share it privately. |
Sure. I'll try to make a demo to reproduce it. |
@KynoYang A demo project to reproduce it would be the best!!! Thanks a lot! |
@beeender Unfortunately, I failed to reproduce it in the demo. It seems no relation with multiple threads. But I indeed received several crash reports from users. I'll add some log in my app to figure out what's the problem. BTW, one of my users sent me a video about this bug. I guess it's because the change listener in RealmExpandableListAdapter (not sure RealmBaseAdapter has the same problem) doesn't work at that time in some unknown reason. |
Reopen this issue. I am checking with @KynoYang about this. |
@beeender Did you have a chance to look into this? |
Yes, but we have no luck to reproduce it :( |
#2753 is reporting the similar issue, i will try to reproduce it with clues from there. |
Close #2408 RealmResults are synced when calling its listener, since we need to check the table version before calling the listener. So sync it just after advance read won't be an option - in that way, the result's listener won't be triggered. So we notify the global listeners as the last thing to do, at that point, result will be synced already. Also a test case is added to ensure the calling sequence of synced listeners.
Close #2408 RealmResults are synced when calling its listener, since we need to check the table version before calling the listener. So sync it just after advance read won't be an option - in that way, the result's listener won't be triggered. So we notify the global listeners as the last thing to do, at that point, result will be synced already. Also a test case is added to ensure the calling sequence of synced listeners.
Close #2408 RealmResults are synced when calling its listener, since we need to check the table version before calling the listener. So sync it just after advance read won't be an option - in that way, the result's listener won't be triggered. So we notify the global listeners as the last thing to do, at that point, result will be synced already. Also a test case is added to ensure the calling sequence of synced listeners.
|
@Mohsin92 can you provide a bit of background info (Realm version, etc.) and context (when do you see exception, Realm configuration, etc.). |
@Mohsin92 execute your query inside the Realm transaction |
@kneth : Realm 2.3.0 ` try { // I could use try-with-resources here
|
@Zhuinden : yes I tried same you can find in above code. |
apparently so the error is in your code, in that line |
Goal (what do you want to achieve?)
I am changing status of a field in realm table continuously
Expected Results
The status should change in the database
Actual Results (e.g. full stack trace with exception)
Version of Realm and tooling
Realm version(s): compile 'io.realm:realm-android:0.87.5'
Android Studio version: android 1.4
Android version(s) on device/simulator: Device version 5.1,API:22
The text was updated successfully, but these errors were encountered: