add logging to examine issue #2181

# reproduce:
1. click in chat where someone is mentioned.
2. click on the mention
3. go back to first chat

# result:
validSessionId() can be false in onDetach for the second chat when going back to first chat
-> leaveRoom is not executed
-> disposable is not disposed
-> getRoomInfo() continues to execute for old controller
-> e.g. appbar infos can be wrong (wrong avatar/title)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-12-08 17:51:21 +01:00
parent b16a89349b
commit 943dfa2a83
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
3 changed files with 34 additions and 16 deletions

View File

@ -363,11 +363,13 @@ class MainActivity : BaseActivity(), ActionBarProvider {
} }
override fun onBackPressed() { override fun onBackPressed() {
Log.d(TAG, "onBackPressed")
if (router!!.getControllerWithTag(LockedController.TAG) != null) { if (router!!.getControllerWithTag(LockedController.TAG) != null) {
return return
} }
if (!router!!.handleBack()) { if (!router!!.handleBack()) {
Log.d(TAG, "back press was not handled by top controller. call onBackPressed...")
super.onBackPressed() super.onBackPressed()
} }
} }

View File

@ -336,6 +336,8 @@ class ChatController(args: Bundle) :
} }
private fun getRoomInfo() { private fun getRoomInfo() {
logConversationInfos("getRoomInfo")
val shouldRepeat = CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "webinary-lobby") val shouldRepeat = CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "webinary-lobby")
if (shouldRepeat) { if (shouldRepeat) {
checkingLobbyStatus = true checkingLobbyStatus = true
@ -358,11 +360,9 @@ class ChatController(args: Bundle) :
override fun onNext(roomOverall: RoomOverall) { override fun onNext(roomOverall: RoomOverall) {
Log.d(TAG, "getRoomInfo - getRoom - got response: $startNanoTime") Log.d(TAG, "getRoomInfo - getRoom - got response: $startNanoTime")
currentConversation = roomOverall.ocs!!.data currentConversation = roomOverall.ocs!!.data
Log.d(
TAG, logConversationInfos("getRoomInfo#onNext")
"getRoomInfo. token: " + currentConversation?.token +
" sessionId: " + currentConversation?.sessionId
)
loadAvatarForStatusBar() loadAvatarForStatusBar()
setTitle() setTitle()
participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!) participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!)
@ -1739,11 +1739,8 @@ class ChatController(args: Bundle) :
@Suppress("Detekt.TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")
override fun onAttach(view: View) { override fun onAttach(view: View) {
super.onAttach(view) super.onAttach(view)
Log.d( logConversationInfos("onAttach")
TAG,
"onAttach: Controller: " + System.identityHashCode(this).toString() +
" Activity: " + System.identityHashCode(activity).toString()
)
eventBus.register(this) eventBus.register(this)
if (conversationUser?.userId != "?" && if (conversationUser?.userId != "?" &&
@ -1831,11 +1828,8 @@ class ChatController(args: Bundle) :
override fun onDetach(view: View) { override fun onDetach(view: View) {
super.onDetach(view) super.onDetach(view)
Log.d(
TAG, logConversationInfos("onDetach")
"onDetach: Controller: " + System.identityHashCode(this).toString() +
" Activity: " + System.identityHashCode(activity).toString()
)
eventBus.unregister(this) eventBus.unregister(this)
@ -1851,9 +1845,15 @@ class ChatController(args: Bundle) :
if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) { if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) {
ApplicationWideCurrentRoomHolder.getInstance().clear() ApplicationWideCurrentRoomHolder.getInstance().clear()
// why is sessionId = 0 here ?!?! this causes that leaveRoom is not executed and callbacks continue to
// receive which causes bugs!!!
if (inConversation && validSessionId()) { if (inConversation && validSessionId()) {
leaveRoom() leaveRoom()
} else {
Log.e(TAG, "not leaving room (inConversation is false and/or validSessionId is false)")
} }
} else {
Log.e(TAG, "not leaving room...")
} }
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) { if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
@ -1993,7 +1993,8 @@ class ChatController(args: Bundle) :
} }
private fun leaveRoom() { private fun leaveRoom() {
Log.d(TAG, "leaveRoom") logConversationInfos("leaveRoom")
var apiVersion = 1 var apiVersion = 1
// FIXME Fix API checking with guests? // FIXME Fix API checking with guests?
if (conversationUser != null) { if (conversationUser != null) {
@ -3412,6 +3413,18 @@ class ChatController(args: Bundle) :
) )
} }
private fun logConversationInfos(methodName: String) {
if (BuildConfig.DEBUG) {
Log.d(TAG, " | -----------------------------------------------")
Log.d(TAG, " | method: $methodName")
Log.d(TAG, " | ChatController: " + System.identityHashCode(this).toString())
Log.d(TAG, " | roomToken: $roomToken")
Log.d(TAG, " | currentConversation?.displayName: ${currentConversation?.displayName}")
Log.d(TAG, " | currentConversation?.sessionId: ${currentConversation?.sessionId}")
Log.d(TAG, " | -----------------------------------------------")
}
}
companion object { companion object {
private const val TAG = "ChatController" private const val TAG = "ChatController"
private const val CONTENT_TYPE_SYSTEM_MESSAGE: Byte = 1 private const val CONTENT_TYPE_SYSTEM_MESSAGE: Byte = 1

View File

@ -245,6 +245,9 @@ abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = nul
calculateValidParentController() calculateValidParentController()
} }
actionBar!!.title = title actionBar!!.title = title
Log.d(TAG, "setTitle: $title")
} else {
Log.d(TAG, "title was not set!!!!")
} }
} }