meteorify icon indicating copy to clipboard operation
meteorify copied to clipboard

iOS app crash

Open gabdsg opened this issue 3 years ago • 11 comments

If you leave the app in background some time, when back to be active the app crashes and restarts.

gabdsg avatar Aug 21 '20 18:08 gabdsg

@gabdsg Meteor works using socket connections. When you put the app in background for quite sometime, the socket connection breaks.

Meteorify currently checks after a default interval for 60 seconds, and reconnects if the connection is broken.

You can reduce that interval down to 30 seconds or whatver suits your requirements by specifying the heartbeatInterval property during the connection.

Meteor.connect("ws://example.com/websocket",heartbeatInterval: const Duration(seconds: 30));

Let me know if that solves your issue.

ShivamArora avatar Aug 22 '20 10:08 ShivamArora

I tried changing the heartbeatInterval with no luck

gabdsg avatar Aug 22 '20 13:08 gabdsg

I tried changing the heartbeatInterval with no luck

Did you use a connection listener along with the heartbeatInterval?

Please refer to the connectionListener in the documentation.

With reduced heartbeatInterval, you'll get notified of the connection changes in the connection listener more frequently so there by when you get a ConnectionStatus.DISCONNECTED status, you can connect back or display a message to the user accordingly.

ShivamArora avatar Aug 22 '20 13:08 ShivamArora

This only happens in the iOS release version, not in debugging. I have the heartbeatInterval in 15 seconds. I tried to disconnect meteor when the app goes into background and reconnect when it returns to the foreground, but it doesn't work all the time...

gabdsg avatar Aug 24 '20 13:08 gabdsg

Hi @gabdsg , just wanted to check if this issue was resolved?

ShivamArora avatar Dec 01 '20 16:12 ShivamArora

No... I have to disconnect it when it goes into the background

gabdsg avatar Dec 01 '20 16:12 gabdsg

@gabdsg Is it possible to share a snippet of the code where you're handling the network connectivity with Meteor?

ShivamArora avatar Dec 01 '20 16:12 ShivamArora

I have the Meteor.connect before runApp then i have this Timer statusChangeTimer; void didChangeAppLifecycleState(AppLifecycleState state) { appState = state; if (state == AppLifecycleState.paused) { statusChangeTimer = Timer(const Duration(seconds: 15), () { Meteor.disconnect(); statusChangeTimer.cancel(); statusChangeTimer = null; }); } else if (state == AppLifecycleState.resumed) { statusChangeTimer?.cancel(); Meteor.reconnect(); } }

gabdsg avatar Dec 01 '20 18:12 gabdsg

Is there any specific reason why you're using Meteor.connect before the runApp()?

ShivamArora avatar Dec 03 '20 11:12 ShivamArora

Not really, why?

gabdsg avatar Dec 03 '20 21:12 gabdsg

Not sure about how you're handling the state. However, have you tried listening to connection updates?

ShivamArora avatar Dec 05 '20 03:12 ShivamArora