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

iOS: plugin unusable after putting device to sleep, then waking #38

Open
michiyosony opened this issue Apr 20, 2015 · 3 comments
Open

Comments

@michiyosony
Copy link

Steps to reproduce:

  1. Open app that uses the AJ plugin and connect to bus (successfully)
  2. Push power button, blackening screen
  3. Push power button again and unlock device, returning to the app
  4. Attempt to do something with the plugin (e.g. connect to a session)
    Observe crash

When returning to the AllJoyn app (step 3), these messages

029.102 aj_net.c:245 AJ_Net_Recv(): recv() failed. errno="Socket is not connected", status=AJ_ERR_READ
029.102 aj_net.c:251 AJ_Net_Recv(): status=AJ_ERR_READ
029.102 AllJoyn_Cordova.m:1469  -- MainLoopError AJ_UnmarshalMsg returned status=AJ_ERR_READ
ERROR: Main loop had a non-succesful iteration. Exit status: 5 0x5 AJ_ERR_READ029.202 aj_net.c:220 AJ_Net_Recv(buf=0x0x17412fe08, len=16., timeout=1000.)
029.202 aj_net.c:245 AJ_Net_Recv(): recv() failed. errno="Socket is not connected", status=AJ_ERR_READ
029.202 aj_net.c:251 AJ_Net_Recv(): status=AJ_ERR_READ
029.202 AllJoyn_Cordova.m:1469  -- MainLoopError AJ_UnmarshalMsg returned status=AJ_ERR_READ
ERROR: Main loop had a non-succesful iteration. Exit status: 5 0x5 AJ_ERR_READ029.302 aj_net.c:220 AJ_Net_Recv(buf=0x0x17412fe08, len=16., timeout=1000.)
029.302 aj_net.c:245 AJ_Net_Recv(): recv() failed. errno="Socket is not connected", status=AJ_ERR_READ
029.302 aj_net.c:251 AJ_Net_Recv(): status=AJ_ERR_READ
029.302 AllJoyn_Cordova.m:1469  -- MainLoopError AJ_UnmarshalMsg returned status=AJ_ERR_READ
ERROR: Main loop had a non-succesful iteration. Exit status: 5 0x5 AJ_ERR_READ029.401 aj_net.c:220 AJ_Net_Recv(buf=0x0x17412fe08, len=16., timeout=1000.)

are being constantly printed in the Xcode console.

When the crash occurs (on attempting to use plugin, step 4), the error that appears in the Xcode console is dependent upon the action performed:

(Attempted to create a channel in the chat app)

027.463 aj_bus.c:172 AJ_BusBindSessionPort(bus=0x0x17013b6c0, port=27., opts=0x0x0)
027.463 aj_net.c:169 AJ_Net_Send(buf=0x0x17013b6d8)
027.463 aj_net.c:176 AJ_Net_Send(): send() failed. errno="Broken pipe", status=AJ_ERR_WRITE
SENDING ERROR: startAdvertisingName: Failure in AJ_BusBindSessionPort AJ_ERR_WRITE

(Attempted to call a method which could be successfully called prior to pushing power button)

Message id: 33554434
MemberType: 63, MemberSignature: increment >i, IsSecure 0
072.498 aj_net.c:169 AJ_Net_Send(buf=0x0x170127d18)
072.498 aj_net.c:176 AJ_Net_Send(): send() failed. errno="Broken pipe", status=AJ_ERR_WRITE

while Xcode shows the crash at the same point:

libsystem_kernel.dylib`mach_msg_trap:
    0x197940e04 <+0>: movn   x16, #0x1e
    0x197940e08 <+4>: svc    #0x80
->  0x197940e0c <+8>: ret    
@michiyosony
Copy link
Author

Would the goal use case be disconnecting when the app is paused and reconnecting on resume? I see there's a disconnect method that isn't currently exposed in the javascript layer. Or, should the connection continue seamlessly?

@obsoleted
Copy link
Contributor

Good question. There are uses for both types of behavior. I think in the short term probably the pausing/reconnecting is probably going to be the way to go. Keeping the connection alive will probably be fairly complex across the platforms. The plugin should probably throw a disconnected error of some sort now and then the app would naturally try to reconnect when it resumed and had a chance to handle it. This way if in the future the plugin did support more persistent connections applications might not need to change, they just wouldn't get the error.

@vjrantal
Copy link
Contributor

Cordova would have pause and resume events (http://cordova.apache.org/docs/en/edge/cordova_events_events.md.html) that could be reacted to for connect (and disconnect if plugin API would expose that).

Reacting to those automatically in the plugin might not always be the wanted behavior, because at least according to the docs, pause "fires when the native platform puts the application into the background", but my guess is that the app might still be running in the background depending on if the OS has enough resources to run apps in background. So, if reacting automatically, we might kill the connection unnecessarily in some cases.

I think easiest option to implement (and maybe also easy-enough for plugin users) would be what is described in above comment so that plugin fires an error event if connection drops and the app can connect again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants