Skip to content
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

crash on RealmList<RealmAny> updates observing #4767

Closed
vcimka opened this issue Jun 17, 2021 · 3 comments · Fixed by #4770
Closed

crash on RealmList<RealmAny> updates observing #4767

vcimka opened this issue Jun 17, 2021 · 3 comments · Fixed by #4770
Assignees

Comments

@vcimka
Copy link

vcimka commented Jun 17, 2021

SDK and version

SDK : io.realm:realm-gradle-plugin
Version: 10.6.0

Observations

  • How frequent do the crash occur? - always
  • Can the crash be reproduced by you? - yes
  • Can you provide instructions for how we can reproduce it? - yes

Crash log / stacktrace

E/REALM: /tmp/realm-java@2/realm/realm-library/src/main/cpp/realm-core/src/realm/object-store/impl/deep_change_checker.cpp:164: [realm-core-11.0.2] Unreachable code
    <backtrace not supported on this platform>!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose

Steps & Code to Reproduce

  class MainActivity : AppCompatActivity(), CoroutineScope {
  
      override val coroutineContext: CoroutineContext = SupervisorJob() + Dispatchers.IO
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          initDb()
          observeChanges()
          launch {
              (0..10).forEach {
                  saveEntities()
                  delay(300)
              }
          }
      }
  
      private fun initDb() {
          Realm.init(applicationContext)
  
          val directory =
              File(applicationContext.filesDir.absolutePath + File.separator + "app_db")
  
          val config = RealmConfiguration.Builder()
              .directory(directory)
              .deleteRealmIfMigrationNeeded()
              .build()
  
          Realm.setDefaultConfiguration(config)
      }
  
      private fun observeChanges() {
          val realm = Realm.getDefaultInstance()
  
          val listener = RealmChangeListener<RealmResults<TestEntity>> {
              it.forEach { entity ->
                  Log.e("Test", "${entity.id} with innerCount: ${entity.items?.size}")
              }
          }
  
          realm.where(TestEntity::class.java).findAllAsync().addChangeListener(listener)
      }
  
      private fun saveEntities() {
  
          val realm = Realm.getDefaultInstance()
          val from = Random.nextInt(30, 100)
          val to = Random.nextInt(100, 10000)
  
          val entities = (from..to).realmMap {
  
              val innerEntities = (0..10).realmMap {
                  RealmAny.valueOf(
                      TestInnerEntity(
                          id = it.toLong()
                      )
                  )
              }
  
              TestEntity(
                  id = it.toLong(),
                  items = innerEntities
              )
          }
  
          realm.executeTransaction {
              it.copyToRealmOrUpdate(entities)
          }
      }
  
      inline fun <T, R> Iterable<T>.realmMap(transform: (T) -> R): RealmList<R> {
          return mapTo(RealmList(), transform)
      }
  }

open class TestEntity( @PrimaryKey var id: Long = 0, var items: RealmList<RealmAny>? = null ) : RealmObject()

open class TestInnerEntity( @PrimaryKey var id: Long = 0 ) : RealmObject()

@vcimka vcimka changed the title crash on RealmAny updates observing crash on RealmList<RealmAny> updates observing Jun 17, 2021
@ironage
Copy link
Contributor

ironage commented Jun 17, 2021

@Stefanos65535 thanks for reporting this, there is a fix underway.

@fealebenpae fealebenpae linked a pull request Jun 21, 2021 that will close this issue
2 tasks
@vcimka
Copy link
Author

vcimka commented Jul 1, 2021

any updates?

@ironage
Copy link
Contributor

ironage commented Jul 6, 2021

Hi @Stefanos65535 the fix has been released in realm-java 10.6.1. Please try it out and let us know if you have any further issues.

@ironage ironage closed this as completed Jul 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants