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

Bugfix/noid/fix websocket connection for chat #4448

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

mahibi
Copy link
Collaborator

@mahibi mahibi commented Nov 14, 2024

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

As remote server is empty instead null when not available, the check was also true when no remote server was in use.

Signed-off-by: Marcel Hibbe <[email protected]>
The request seems to cause problems so blockingSubscribe doesn't seem to be a good choice here. This commit will replace blockingSubscribe by subscribe and modify the related code in order to be executed when the request succeeds.
The root cause why the request seems to cause problems may have to be analyzed further.

I was not able to reproduce the ANR without this PR, however the following error was reported on gplay console very often!:

      at jdk.internal.misc.Unsafe.park (Native method)
      at java.util.concurrent.locks.LockSupport.park (LockSupport.java:341)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block (AbstractQueuedSynchronizer.java:506)
      at java.util.concurrent.ForkJoinPool.unmanagedBlock (ForkJoinPool.java:3466)
      at java.util.concurrent.ForkJoinPool.managedBlock (ForkJoinPool.java:3437)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:1623)
      at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:435)
      at io.reactivex.internal.operators.observable.ObservableBlockingSubscribe.subscribe (ObservableBlockingSubscribe.java:56)
      at io.reactivex.Observable.blockingSubscribe (Observable.java:5552)
      at com.nextcloud.talk.chat.ChatActivity.setupWebsocket (ChatActivity.kt:2445)
      at com.nextcloud.talk.chat.ChatActivity.joinRoomWithPassword (ChatActivity.kt:2402)
      at com.nextcloud.talk.chat.ChatActivity.initObservers$lambda$13 (ChatActivity.kt:594)
      at com.nextcloud.talk.chat.ChatActivity.$r8$lambda$QKH5JCFLmCzRMlSJ-EV-m4IW5ig (unavailable)
      at com.nextcloud.talk.chat.ChatActivity$$ExternalSyntheticLambda38.invoke (D8$$SyntheticClass)
      at com.nextcloud.talk.chat.ChatActivity$sam$androidx_lifecycle_Observer$0.onChanged (unavailable:2)
      at androidx.lifecycle.LiveData.considerNotify (LiveData.java:133)
      at androidx.lifecycle.LiveData.dispatchingValue (LiveData.java:151)
      at androidx.lifecycle.LiveData.setValue (LiveData.java:309)
      at androidx.lifecycle.MutableLiveData.setValue (MutableLiveData.java:50)
      at com.nextcloud.talk.chat.viewmodels.ChatViewModel.getCapabilities (ChatViewModel.kt:240)
      at com.nextcloud.talk.chat.ChatActivity$initObservers$1$1.invokeSuspend (ChatActivity.kt:553)
      at com.nextcloud.talk.chat.ChatActivity$initObservers$1$1.invoke (unavailable:8)
      at com.nextcloud.talk.chat.ChatActivity$initObservers$1$1.invoke (unavailable:4)
      at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit (Emitters.kt:219)
      at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catchImpl$2.emit (Errors.kt:154)
      at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit (Emitters.kt:220)
      at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl (SharedFlow.kt:392)
      at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend (unavailable:15)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
      at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104)
      at android.os.Handler.handleCallback (Handler.java:938)
      at android.os.Handler.dispatchMessage (Handler.java:99)
      at android.os.Looper.loopOnce (Looper.java:210)
      at android.os.Looper.loop (Looper.java:299)
      at android.app.ActivityThread.main (ActivityThread.java:8168)
      at java.lang.reflect.Method.invoke (Native method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1037)

Signed-off-by: Marcel Hibbe <[email protected]>
however i was not able to see onDestroy being executed.

anyway, disposables won't be necessary when coroutine is used.

also: remove a useless outdated log line

Signed-off-by: Marcel Hibbe <[email protected]>
@mahibi mahibi force-pushed the bugfix/noid/fixWebsocketConnectionForChat branch from dc54718 to acd9648 Compare November 14, 2024 12:41
@mahibi mahibi self-assigned this Nov 14, 2024
@mahibi mahibi added the 3. to review Waiting for reviews label Nov 14, 2024
@mahibi mahibi added this to the 20.1.0 milestone Nov 14, 2024
Copy link
Contributor

Codacy

Lint

TypemasterPR
Warnings94152
Errors13288

SpotBugs

CategoryBaseNew
Bad practice66
Correctness1616
Dodgy code7474
Internationalization33
Malicious code vulnerability33
Performance55
Security11
Total108108

Lint increased!

Copy link
Contributor

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/4448-talk.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud Talk app.

Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested, but the changes make sense and look good 👍

Approved, as I guess that the disposable does what I expected it to do, but please check the comment before merging :-)

@mahibi mahibi merged commit 89964c0 into master Nov 14, 2024
18 of 19 checks passed
@mahibi mahibi deleted the bugfix/noid/fixWebsocketConnectionForChat branch November 14, 2024 14:54
@mahibi mahibi modified the milestones: 20.1.0, 20.0.4 Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants