Skip to content

Issues with thousands of objects #281

@jpmcosta

Description

@jpmcosta

Issue Basics

  • ObjectBox version: 1.2.1
  • Reproducibility:
    • Issue 1: always
    • Issue 2 most times, it some persistence to reproduce

Reproducing the bug

Description

I have created a project to test ObjectBox's performance with thousands of objects:
https://github.com/jpmcosta/ObjectBoxTestProject/tree/ab97ac23ce6fa408f1313992fc72091fd52b3a9d

I have found 2 issues that I'm going to describe here as they seem to be related and I think it would be spammy to create multiple issues.

Code summary

The project has an App class that recreates data on each run. You can specify ITEM_COUNT and NOTE_COUNT_PER_ITEM to change the number of objects created.

A ProjectAdapter (ItemListAdapter) is used to display items of a project in a RecyclerView, using the following query:

fun BoxStore.getProjectItemsQuery(id: Long): Query<Item> =
        boxFor(Item::class.java).query()
                .equal(Item_.parentProjectId, id)
                .build()

When you click on an item in the list, Item.isActive is toggled.

Entities

@Entity
class Project {
    
    @Id
    var id: Long = NEW_ID

    @Backlink
    lateinit var items: ToMany<Item>
}
@Entity
class Item {

    @Id
    var id: Long = NEW_ID

    var isActive: Boolean = true

    @Backlink
    lateinit var notes: ToMany<Note>

    lateinit var parentProject: ToOne<Project>
}
@Entity
class Note {

    @Id
    var id: Long = NEW_ID

    var text: String? = null

    lateinit var parentItem: ToOne<Item>
}

Issue 1

If you set ITEM_COUNT to 20K and NOTE_COUNT_PER_ITEM to 4 (total: 80K objects), the objects are never created (I've waited a few minutes).

Issue 2

If you set ITEM_COUNT to 20K/80K and NOTE_COUNT_PER_ITEM to 0 (total: 20K/80K objects), the objects are created. However, there are 2 issues:

  • there's lag when toggling Item.isActive (I guess that's just a limitation)
  • if you click repeatedly on items in the list, eventually the DataObserver defined in ProjectAdapter will stop getting notified of changes. The toggle operation will still work (you can test that by scrolling the list to check if the item has changed).
    • to reproduce this issue it helps to spam click multiple items at the same time

Misc

I couldn't reproduce those issues when I removed @Backlink annotation from Item.notes AND removed parentItem property from Note.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions