element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
GNU Affero General Public License v3.0
3.39k stars 732 forks source link

room TimelineEvent is null when receive notification #4705

Open hafiz013 opened 2 years ago

hafiz013 commented 2 years ago

Steps to reproduce

  1. Where are you starting? What can you see? -null
  2. What do you click? nothing
  3. More steps…

sample code : val eventId = intent.getStringExtra("event_id") val roomId = intent.getStringExtra("room_id")

val matrix = Matrix.getInstance(context) val matrixAuthService = matrix.authenticationService() if(matrixAuthService.hasAuthenticatedSessions()) { try { //matrixAuthService.getLastAuthenticatedSession()?.requireBackgroundSync() var session = matrixAuthService.getLastAuthenticatedSession() var room = session?.getRoom(roomId ?: "") var timelineEvent = room?.getTimeLineEvent(eventId ?: "")

                           Timber.d("timelineEvent: ${timelineEvent}")  <--- give null why?
                       }catch (e: Exception) {
                           Timber.d("ErrorNotification: ${e.message.toString()}")
                       }catch (e: RealmFileException){
                       }
                   }

Outcome

What did you expect?

-list of timeline

What happened instead?

Your phone model

xiomi 9t

Operating system version

android 10

Application version and app store

No response

Homeserver

No response

Will you send logs?

Yes

hafiz013 commented 2 years ago

room.getAttachmentMessages() = {ArrayList@19212} size = 0 room.getTimeLineEventLive(eventId ?: "") = {LiveTimelineEvent@19220} coroutineScope = {ContextScope@19221} "CoroutineScope(coroutineContext=SupervisorJobImpl{Active}@4b33df7)" coroutineContext = {SupervisorJobImpl@19257} "SupervisorJobImpl{Active}@4b33df7" handlesException = false _parentHandle = {NonDisposableHandle@19260} "NonDisposableHandle" _state = {NodeList@19261} "NodeList@e102be8" shadow$klass = {Class@10926} "class kotlinx.coroutines.SupervisorJobImpl" shadow$monitor = -2068627977 shadow$klass = {Class@10968} "class kotlinx.coroutines.internal.ContextScope" accessFlags = 524305 classFlags = 0 classLoader = {PathClassLoader@15971} "dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.nibmeetings.android-3v_KE_HmGFbCDdy7oOo2jA==/base.apk"],nativeLibraryDirectories=[/data/app/com.nibmeetings.android-3v_KE_HmGFbCDdy7oOo2jA==/lib/arm64, /data/app/com.nibmeetings.android-3v_KE_HmGFbCDdy7oOo2jA==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]]" classSize = 232 clinitThreadId = 20295 componentType = null copiedMethodsOffset = 3 dexCache = {DexCache@19265} dexClassDefIndex = 2656 dexTypeIndex = 2979 extData = null iFields = 539464613392 ifTable = {Object[2]@19266} methods = 539464613416 name = "kotlinx.coroutines.internal.ContextScope" numReferenceInstanceFields = 1 numReferenceStaticFields = 0 objectSize = 12 objectSizeAllocFastPath = 16 primitiveType = 131072 referenceInstanceOffsets = 1 sFields = 0 status = -536870912 superClass = {Class@7867} "class java.lang.Object" virtualMethodsOffset = 1 vtable = null shadow$klass = {Class@6071} "class java.lang.Class" shadow$monitor = 0 shadow$monitor = 0 eventId = "$Ztk52wL924_NkLw5Dlw4qoBXv7bDl1DT5g2ZpYwV9A0" count = 88 hash = 0 shadow$klass = {Class@6477} "class java.lang.String" shadow$monitor = 0 initialLiveData = null monarchy = {Monarchy@19183} LOCK = {Object@19272} handler = {AtomicReference@19273} "Handler (android.os.Handler) {bb7a8a6}" handlerThread = {AtomicReference@19274} "Thread[MONARCHY_REALM-#188932028,5,main]" isForcedOpen = {AtomicBoolean@19275} "false" realmConfiguration = {RealmConfiguration@19276} "realmDirectory: /data/user/0/com.nibmeetings.android/files/6e7a7894138c3a0abee05700dee42273\nrealmFileName : disk_store.realm\ncanonicalPath: /data/user/0/com.nibmeetings.android/files/6e7a7894138c3a0abee05700dee42273/disk_store.realm\nkey: [length: 64]\nschemaVersion: 17\nmigration: org.matrix.android.sdk.internal.database.RealmSessionStoreMigration@8f992e7\ndeleteRealmIfMigrationNeeded: false\ndurability: FULL\nschemaMediator: io.realm.SessionRealmModuleMediator@6b6cd2cb\nreadOnly: false\ncompactOnLaunch: io.realm.DefaultCompactOnLaunchCallback@2b01e94\nmaxNumberOfActiveVersions: 9223372036854775807" realmThreadLocal = {ThreadLocal@19277} refCount = {AtomicInteger@19278} "78" resultsRefs = {Monarchy$2@19279} writeScheduler = {Executors$FinalizableDelegatedExecutorService@19280} shadow$klass = {Class@9771} "class com.zhuinden.monarchy.Monarchy" shadow$monitor = -1958551620 roomId = "!HFViIrrcjKzjBYURmG:worqapp.com" count = 62 hash = 0 shadow$klass = {Class@6477} "class java.lang.String" shadow$monitor = 0 timelineEventMapper = {TimelineEventMapper@19188} mSources = {SafeIterableMap@19222} "[]" mActiveCount = 0 mChangingActiveState = false mData = {Object@19223} mDataLock = {Object@19224} mDispatchInvalidated = false mDispatchingValue = false mObservers = {SafeIterableMap@19225} "[]" mPendingData = {Object@19223} mPostValueRunnable = {LiveData$1@19226} mVersion = -1 shadow$klass = {Class@17901} "class org.matrix.android.sdk.internal.session.room.timeline.LiveTimelineEvent" shadow$monitor = 0 this = {NotificationReceiver@18890} context = {ReceiverRestrictedContext@19101} intent = {Intent@19102} "Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x11000010 pkg=com.nibmeetings.android cmp=com.nibmeetings.android/.broadcast.NotificationReceiver (has extras) }" eventId = "$Ztk52wL924_NkLw5Dlw4qoBXv7bDl1DT5g2ZpYwV9A0" roomId = "!HFViIrrcjKzjBYURmG:worqapp.com" matrix = {Matrix@19105} matrixAuthService = {DefaultAuthenticationService@19114} session = {DefaultSession@19124} "@61937d6d8fad9d001c0e3eed:worqapp.com - MQRKPHYQCJ" room = {DefaultRoom@19140} timelineEvent = null

hafiz013 commented 2 years ago

@bmarty any idea?