Uncaught Exception in Firebase Runloop (3.0.0)

Uncaught exception in Firebase runloop (3.0.0)

We are facing the same issue on version 9.0.2 and 9.2.0. After many hours of investigation, we found that one way to reproduce this issue is to have a query with fixed endAt and startAt parameters. Let me explain with a sample code:

// Firebase dependencies
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'

...

public class MainActivity extends AppCompatActivity {

private FirebaseDatabase m_Database;
private static boolean s_persistenceInitialized = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

m_Database = FirebaseDatabase.getInstance();

if (!s_persistenceInitialized) {
m_Database.setPersistenceEnabled(true);
s_persistenceInitialized = true;
}

m_Database.setLogLevel(Level.DEBUG);
}

@Override
protected void onStart() {
super.onStart();

long endAt = 100L; // Fixed value: CRASH on third app restart
// long endAt = new Date().getTime(); // Dynamic value: NO CRASH
getGoal("min_per_day", endAt, "some_uid");
}

private void getGoal(String p_goalId, long p_endAt, String p_uid) {
Query ref = m_Database.getReference("v0/data/meditation/goals").child(p_goalId).child(p_uid)
.orderByChild("time").endAt(p_endAt).limitToLast(1);

ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("FB", "Snapshot: " + dataSnapshot);
}

@Override
public void onCancelled(DatabaseError error) {
Log.e("FB", "Error: " + error);
}
});
}
}

So the fixed endAt param will crash the app on third start. I assume queries are cached to disk and then corrupted at some point if we recreate the same query from local cache multiple times (three). On the other hand, if endAt is not fixed, for example current time in millis, then everything works as expected. The same applies for startAt query parameter.

Uncaught exception in Firebase runloop (3.0.0) workaround for Strings

Looks like the problem has been solved in the latest update of the Firebase SDK,
Version 9.6 - September 21, 2016

https://firebase.google.com/support/release-notes/android#9.6

Why when i´m trying to write in Firebase Database I got this error? Related with FirebaseApp$IdTokenListener

my problem was solved just upgrading firebase database version to 17:

implementation 'com.google.firebase:firebase-database:17.0.0'

Hope it will help to someone.



Related Topics



Leave a reply



Submit