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

[BUG] Crash upon starting listening for real time chat events #862

Closed
LosDanieloss opened this issue Sep 3, 2021 · 4 comments · Fixed by #898
Closed

[BUG] Crash upon starting listening for real time chat events #862

LosDanieloss opened this issue Sep 3, 2021 · 4 comments · Fixed by #898
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Communication customer-reported Issues that are reported by GitHub users external to the Azure organization.

Comments

@LosDanieloss
Copy link

LosDanieloss commented Sep 3, 2021

Describe the bug
To long Log tag on Android running <= API 25

Exception or Stack Trace
E/AndroidRuntime( 7159): Caused by: java.lang.IllegalArgumentException: Log tag "com.azure.android.communication.chat.ChatAsyncClient" exceeds limit of 23 characters
E/AndroidRuntime( 7159):
E/AndroidRuntime( 7159): at android.util.Log.isLoggable(Native Method)
E/AndroidRuntime( 7159): at com.azure.android.core.logging.implementation.DefaultLogger.isErrorEnabled(DefaultLogger.java:233)
E/AndroidRuntime( 7159): at com.azure.android.core.logging.ClientLogger.logThrowableAsError(ClientLogger.java:225)
E/AndroidRuntime( 7159): at com.azure.android.core.logging.ClientLogger.logExceptionAsError(ClientLogger.java:209)
E/AndroidRuntime( 7159): at com.azure.android.communication.chat.ChatAsyncClient.addEventHandler(ChatAsyncClient.java:285)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsIntegration$chatClient$2.invoke(AcsIntegration.kt:81)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsIntegration$chatClient$2.invoke(AcsIntegration.kt:18)
E/AndroidRuntime( 7159): at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsIntegration.getChatClient(AcsIntegration.kt)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsIntegration.access$getChatClient$p(AcsIntegration.kt:18)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsIntegration$getDirectMessages$1.subscribe(AcsIntegration.kt:232)
E/AndroidRuntime( 7159): at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
E/AndroidRuntime( 7159): at io.reactivex.Single.subscribe(Single.java:3603)
E/AndroidRuntime( 7159): at io.reactivex.internal.operators.single.SingleObserveOn.subscribeActual(SingleObserveOn.java:35)
E/AndroidRuntime( 7159): at io.reactivex.Single.subscribe(Single.java:3603)
E/AndroidRuntime( 7159): at io.reactivex.Single.subscribe(Single.java:3589)
E/AndroidRuntime( 7159): at io.reactivex.Single.subscribe(Single.java:3559)
E/AndroidRuntime( 7159): at com.microsoft.pulsyksometr.pulsyksometr_app.acs.AcsInitializer$setup$1.onMethodCall(AcsInitializer.kt:191)
E/AndroidRuntime( 7159): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/AndroidRuntime( 7159): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/AndroidRuntime( 7159): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/AndroidRuntime( 7159): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime( 7159): at android.os.MessageQueue.next(MessageQueue.java:143)
E/AndroidRuntime( 7159): at android.os.Looper.loop(Looper.java:122)
E/AndroidRuntime( 7159): ... 5 more

To Reproduce
Add code snippet found below to your App and connect. Important bit is adding event handler to receive real time notification. Then just launch the App & send some message to that user. That should create the crash I believe.

Code Snippet
ChatClientBuilder()
.endpoint(endpoint)
.credential(CommunicationTokenCredential(userAccessToken))
.buildAsyncClient().apply {
val notificationCallback =
RealTimeNotificationCallback { chatEvent -> }
this.addEventHandler(ChatEventType.CHAT_MESSAGE_RECEIVED, notificationCallback)
this.startRealtimeNotifications(userAccessToken, context)
}

Expected behavior
App won't crash & will be able to listen to new messages.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Android 5.0, 6.0, 7.1.1
  • IDE : Android Studio Arctic Fox | 2020.3.1 Patch 1
    Build #AI-203.7717.56.2031.7621141, built on August 7, 2021
    Runtime version: 11.0.10+0-b96-7249189 amd64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    Linux 5.4.0-58-generic
    GC: G1 Young Generation, G1 Old Generation
    Memory: 4096M
    Cores: 8
    Registry: external.system.auto.import.disabled=true, ide.images.show.chessboard=true
    Non-Bundled Plugins: com.bloc.intellij_generator_plugin, Dart, com.localizely.flutter-intl, org.jetbrains.kotlin, io.flutter, org.intellij.plugins.markdown
    Current Desktop: X-Cinnamon
  • Version of the Library used: com.azure.android:azure-communication-chat:1.1.0-beta.2
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 3, 2021
@LosDanieloss LosDanieloss changed the title [BUG] [BUG] Crash upon starting listening for real time chat events Sep 6, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 8, 2021
@vcolin7 vcolin7 added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Sep 8, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 8, 2021
@vcolin7 vcolin7 removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Sep 8, 2021
@vcolin7
Copy link
Member

vcolin7 commented Sep 8, 2021

@CHILIU-MSFT would you mind taking a look? Thanks!

@CHILIU-MSFT
Copy link
Member

Hi @LosDanieloss , thanks for feedback!

The design is startRealtimeNotifications need to be called before addEventHandler.
Could you give it a try to see whether this could unblock your scenario?

this.startRealtimeNotifications(userAccessToken, context)
this.addEventHandler(ChatEventType.CHAT_MESSAGE_RECEIVED, notificationCallback)

Besides, we'll look into the Log tag exceeds limit issue. Thanks for reporting the bug!

@ghost
Copy link

ghost commented Sep 20, 2021

Hi @CHILIU-MSFT

I am working on the same application as @LosDanieloss . I’ve checked our original code in the app and this.startRealtimeNotifications and this.addEventHandler are already called in the order you wrote. It looks like as Daniel wrote that our problem for Android < 8.0 is tag length. We're looking forward for the fixed version.

@vcolin7
Copy link
Member

vcolin7 commented Oct 4, 2021

Hi @LosDanieloss, @michal-softwarehut. I did some research and it looks like we cannot remove the tag limit since it resides in the Android API Log.isLoggable() for lower Android API levels, what we can do though, is make sure we don't ever pass a tag longer than what's allowed in those cases. I will look into this and most likely include a fix for next month's release.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Communication customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants