ably-flutter
ably-flutter copied to clipboard
Fatal error after network connection issues
Steps to reproduce:
- Open app and start Ably connection
- Turn off network connection
- Hot restart
Expected state: Later after restoring network connection Ably also restores its websocket connection.
Actual state: Ably throws errors:
======== Exception caught by services library ======================================================
The following _TypeError was thrown during a platform message callback:
type 'ChannelStateChange' is not a subtype of type 'PresenceMessage' in type cast
When the exception was thrown, this was the stack:
#0 StreamsChannel.receiveBroadcastStream.<anonymous closure>.<anonymous closure> (package:ably_flutter/src/platform/src/streams_channel.dart:65:56)
#1 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:603:35)
#2 _invoke2 (dart:ui/hooks.dart:344:13)
#3 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#4 _Channel._drainStep (dart:ui/channel_buffers.dart:228:31)
(elided 2 frames from dart:async)
====================================================================================================
======== Exception caught by services library ======================================================
The following _TypeError was thrown during a platform message callback:
type 'ChannelStateChange' is not a subtype of type 'PresenceMessage' in type cast
When the exception was thrown, this was the stack:
#0 StreamsChannel.receiveBroadcastStream.<anonymous closure>.<anonymous closure> (package:ably_flutter/src/platform/src/streams_channel.dart:65:56)
#1 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:603:35)
#2 _invoke2 (dart:ui/hooks.dart:344:13)
#3 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#4 _Channel._drainStep (dart:ui/channel_buffers.dart:228:31)
(elided 2 frames from dart:async)
====================================================================================================
and even when I turn on internet connection the websocket connection is never restarted. (Yes, I waited more than a couple of minutes).
Regardless of whether you can reproduce it or not, it's still worth looking into, because clearly some messages here were propagated that Dart code wasn't expecting.
This is important bug, because when app is in background and system may kill app or limit it's resources, it's likely that Ably will enter this state and cause websocket events to stop working until app is killed and restarted again.