node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

[Regression] [PWA?] Widgets not receiving messages after sleep on Android

Open colinl opened this issue 1 year ago • 5 comments

Current Behavior

There has been a change in behaviour of some sort recently, I think probably with the release of 1.15.0. Now, occasionally, on Android if the dashboard is left open and the device left alone for several hours, then on waking the device up the widgets no longer receive updates.

On waking there is no connection failed/recovered popup seen. Navigation operates normally but widgets are never updated and the widgets apparently do not send messages back to node-red.

I managed to repeat it with a debug build of one of my widgets, and using the remote monitor in Chrome, can see that when a page is opened mounted is called and the widget receives its props message. On widget-load is never called though, and it receives no further messages. Note that this is not a recurrence of #444 which was triggered by a failure to reconnect after a network failure.

To recover it is necessary to force a page refresh.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • Dashboard version: 1.15.0
  • Node-RED version: 4.0.2
  • Node.js version: 20
  • npm version:
  • Platform/OS: Android
  • Browser: Edge

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

colinl avatar Aug 31 '24 15:08 colinl

I can't get it to fail when running normally in Chrome (in Android). I have only had it fail when running the PWA, so I think this is probably a factor. If anyone can suggest any additional logging I can put in to identify why widget-load does not happen then I will gladly do that.

colinl avatar Sep 02 '24 08:09 colinl

suggest any additional logging I can put in to identify why widget-load does not happen

@colinl, Personally I would add some extra logging in the ui_base.js file, since that is the place where a lot of magic happens.

And perhaps you can find any clues in this diagram by following the arrows. Although some arrows might be missing or changed meanwhile...

I think probably with the release of 1.15.0

When I look at that release, I see that they have implemented PR 1123 to support our developments. The title of that PR contains "... update widget-load behaviour" which might be related to your question? When you look at the introduced changes , could perhaps the updated IF condition have altered your behaviour in any way:

image

Just thinking out loud. Perhaps it has absolutely nothing to do with your problem...

bartbutenaers avatar Sep 02 '24 19:09 bartbutenaers

Thanks, I will have a look.

colinl avatar Sep 02 '24 20:09 colinl

Perhaps it has absolutely nothing to do with your problem...

Maybe not, but it has been useful. I added debug and can see that the function async function handler () is not being called when the problem arises. When I switch pages I can see that, in the client, mounted is called and the correct props data is received, but handler is not called in the server. I have added debug to check whether onLoad() is called in the server. Any other suggestions gratefully received.

colinl avatar Sep 10 '24 10:09 colinl

I see I have been labouring under a misapprehension. I assumed that, since mounted is called, that the client is actually receiving data from the server. But having now stopped the server I see that there is no change in the symptoms at the client. It is not showing the disconnected message, and still switches screens, and mounted is called (presumably with old data), but nothing else happens. So the fundamental issue may be that the client has become disconnected but does not realise that this is the case. I am using Google auth with Cloudflare Zero Trust, and I think the situation under which this occurs is when the token expires while the dashboard is in the background. When I wake it, it shows the login screen, but having logged on it returns to the dashboard, but it is not connected to the server for some reason.

colinl avatar Sep 10 '24 10:09 colinl