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

PlatformException #463

Open
TheManuz opened this issue Apr 14, 2023 · 7 comments
Open

PlatformException #463

TheManuz opened this issue Apr 14, 2023 · 7 comments
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@TheManuz
Copy link

TheManuz commented Apr 14, 2023

I'm getting these PlatformException reports in Firebase Crashlytics from ably_flutter package.

Stacktrace attached.
com.atono.droppay_issue_651deded2d2148c2f3126a4ecfef5e5b_crash_session_6438ED7702140001717933A6E2DCBB88_DNE_0_v2_stacktrace.txt

┆Issue is synchronized with this Jira Bug by Unito

@sync-by-unito
Copy link

sync-by-unito bot commented Apr 14, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3537

@mikelee638
Copy link

Hi @TheManuz, thanks for bringing this to our attention and providing the stack trace. For clarity, can you provide the versions of ably-flutter, Flutter, and Android where this exception is occurring?

@TheManuz
Copy link
Author

Thanks for investigating the exception.

We have 59 reports of this crash on 35 users, with these specifics:

  • ably-flutter version 1.2.15
  • flutter version flutter: 3.7.9
  • Android versions
    • 73% Android 13
    • 22% Android 12
    • 2% Android 8
    • 2% Android 9
    • 1% Android 10
  • Devices
    • 92% Samsung
      • 22% Galaxy A71
      • 10% Galaxy S10+
      • 9% Galaxy S22
      • 51% Others
    • 5% Huawei
      • 2% Huawei Y6s
      • 2% Y7 Prime 2019
      • 1% P20 Pro
    • 3% Oppo
      • 3% Realme 7

I could also provide the stacktraces for all 59 exceptions, even if they're all pretty similar.

If you need them or other informations, feel free to ask.

@ikbalkaya
Copy link
Contributor

ikbalkaya commented Apr 18, 2023

@TheManuz Would it be possible to provide some details on how you use this SDK please? especially in terms of anything related to threading. The log shows that network calls are happening on main thread which seems a bit strange as SDK should be executing network operations on a background thread

@TheManuz
Copy link
Author

Sure, this is the class that uses ably_flutter:

import 'package:ably_flutter/ably_flutter.dart';
import 'package:async/async.dart';
import 'package:my_app/core/logger.dart';
import 'package:my_app/notification/API/druid_notification.api.dart';
import 'package:my_app/notification/model/rtcManagers/rtc_manager.dart';

class AblyRtcManager extends RtcManager {
  final Realtime realtime;

  AblyRtcManager({
    required String token,
    required super.environment,
    required super.uuid,
  }) : realtime = Realtime(
          options: ClientOptions(
            key: token,
            authCallback: (TokenParams params) async {
              final result = await GetAblyRtcToken().consume();
              return result.data!["token"] as String;
            },
          ),
        );

  void _connectionStateListener(ConnectionStateChange stateChange) {
    logger.d('$runtimeType connection state: ${stateChange.current}');
  }

  @override
  Stream<Map<String, dynamic>> subscribeToAllChannels() {
    realtime.connection
        .on(ConnectionEvent.connected)
        .listen(_connectionStateListener);

    final streams = channels.map(
      (String channel) => realtime.channels.get(channel).subscribe(),
    );

    return StreamGroup.merge(streams).map(
      // Ably returns a Map<Object?, Object?>, must be converted
      (m) => Map<String, dynamic>.from(m.data as Map<Object?, Object?>),
    );
  }

  @override
  void unsubscribeToAllChannels() {
    void releaseChannel(channel) => realtime.channels.release(channel);
    channels.forEach(releaseChannel);
  }
}

You say that network calls are happening on the main thread, but I'm not sure I have control on this, since these network calls happen on the Android layer (which is handle by ably-flutter plugin), and not on the Flutter layer.

I hope that this these informations helps.

@ikbalkaya
Copy link
Contributor

Thanks @TheManuz That's really helpful. I will investigate this further later.

Just to be clear on network thread running on main thread, I don't think it's something to do with what you are doing. This is something that our SDK should handle.

@sync-by-unito sync-by-unito bot added the bug Something isn't working. It's clear that this does need to be fixed. label Apr 26, 2023
@ikbalkaya ikbalkaya removed their assignment Apr 28, 2023
@sync-by-unito
Copy link

sync-by-unito bot commented Apr 28, 2023

➤ Ikbal Kaya commented:

There is a MainThreadSink in Android plugin that runs everything on main thread and this issue happens when a connection fails (that is called in a background thread) and subsequently invokes a network call. (checkFallbackHosts). I don’t want to change this behaviour, since function execution from plugins to dart side (not yet sure) has to be done from main thread. It might be better for someone for a more knowledge on Flutter plugin look into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

3 participants