aprsworld / wsWebDisplay

0 stars 0 forks source link

Cameras do not resume after hibernation #101

Open Cdetviler opened 8 years ago

Cdetviler commented 8 years ago

Jim has reported that cameras have not been automatically resuming with updates when he comes back from hibernation. Today, I tested this multiple times using different cases.

Case 1

Steps taken: I loaded both madeline cameras using the layout. I then hibernated the desktop and disconnected the network cable. I waited until I knew both cameras had updated and then I resumed the computer. After resuming I waited about 10 seconds and plugged in the network cable.

Result: Both cameras updated immediately

Case 2

Steps taken: I loaded both madeline cameras using the layout. I then hibernated the desktop whilst keeping the networking connection active. I waited until I knew both cameras had updated and then I resumed the computer.

Result: Both cameras updated immediately.

My thought currently is that it has something to do with hibernation over night. I know that the madeline cameras shut down over night so maybe that has something to do with how the bug is produced.

I will have it set to log everything when I leave tonight and then I will hibernate the accounting desktop. I will resume it in the morning and see if I can reproduce the issue.

Cdetviler commented 8 years ago

Case 3

Steps taken: I unplugged A4751 when I got into work this morning and waited the 45 minutes or so for the data to expire. After the data had expired I loaded a layout containing the image for A4751. As expected, it could not find the image and displayed the placeholder image instead. I then started A4751 to see if the image would update.

Result: The image updated as soon as the camera sent the first image and continued updating afterwards.

I am still going to try leaving madeline up tonight in hibernation mode and see if the problem persists tomorrow morning.

Cdetviler commented 8 years ago

Case 4

Steps Taken: I loaded both madeline cameras using the layout. I then hibernated the desktop overnight whilst keeping the networking connection active. The next morning, I resumed the desktop and observed whether the images updated or not.

Result: Both cameras updated immediately.

The next test will be to do this again tomorrow without a network connection. I suspect that the results will be the same but the test should be done just in case.

Cdetviler commented 8 years ago

It seems that these steps and events are what cause the problem:

1) Open page with layout (or empty page and add data) 2) Hibernate with data elements and camera on page 3) Camera(s) shut off/lose power/stop working 4) User resumes computer 5) Cameras start working

The result is that Cameras show old images. I am currently trying to reproduce this by shutting down A4751 while I have an A4751-based layout loaded in my browser.

Cdetviler commented 8 years ago

Per the above comment...

Steps Taken: 1) loaded an A4751-based configuration (since that is the only camera I have control over) 2) hibernated the computer and disconnected from internet. 3) went and disconnected the camera. 4) I waited an hour and checked that the data had expired. 5) resumed the computer from hibernation, waited 10 seconds, and then plugged Ethernet cable in. 6) Waited a couple minutes, and then turned the camera back on

Result: wsWebDisplay loaded the first image that A4751 was able to send and every image thereafter.

Cdetviler commented 8 years ago

I came in this morning and resumed the accounting computer. Within seconds, the Madeline Island cameras updated. Jim sent an email reporting the opposite.

The only difference between our two situations is that Jim resumes his laptop (presumably) while the cameras are still down before 6:30am where as I am resuming my laptop after they have come up ~9:00am.

What's odd is the testing in the comment immediately above this one should have shown the same behavior as what Jim is experiencing.

This problem is no doubt happening as I have seen it on Jim's computer with my own eyes. I'm going to test it again today while I work on other issues related to wsWebDisplay.

Cdetviler commented 8 years ago

I put the accounting computer to sleep last night before I left work. I also scheduled it to wake up at about 5:30am so that I could reproduce the situation that Jim has been describing when he comes into work early in the morning.

I was able to successfully reproduce the issue and I am working towards solving it. I think it may have been the function in charge of refreshing the global data object with new data. I had logic in the function that was meant to add a property to the nested objects if that property was not there before.

I have since changed how it determines the missing property. The subscriptions really help to understand what is going on because I can see, at a glance, exactly what data comes in. I am going to be testing A4751 periodically throughout the day, and I will schedule another wakeup for the accounting computer tomorrow.

Cdetviler commented 8 years ago

I had A4751 unplugged all day and periodically checked for changes on a session that I had open on the accounting computer. After a certain amount of time offline, wsWebDisplay gets rid of the old data in the tree. wsWebDisplay is now re-adding objects to the tree when a new object is detected (per my changes above), which was behavior that before today was not working correctly.

So now when the camera comes back online, it adds data back into the tree as well as the global data object that it did not have before.

However, now that subscriptions are live, it is only receiving very specific data. So here is a scenario where that is problematic:

  1. Add A4751 camera from tree - data comes in because it is subscribed to /A4751/cameras/0
  2. camera goes down

period of time passes

  1. camera is deleted from the global data object and therefore removed from the tree
  2. A4751 camera comes back online
  3. A4751 camera starts sending data, and wsWebDisplay updates it
  4. Unfortunately since the subscription is specific to /A4751/cameras/0, sensor data never comes in unless it too was added previously.

I am still going to schedule a wake up on the accounting computer to test whether or not this actually is working correctly for madeline tomorrow.

Cdetviler commented 8 years ago

I worked on this issue Friday Morning and narrowed down the issue. The logic block within the function that is in charge of updating data was not properly iterating through the incoming object properties. Specifically, it was not correctly adding properties correctly such as the URL for the cameras.

With this fixed, the cameras seem to load if the user resumes before the cameras come back online. However, it seems that some issues remain. Jim loaded his display between 6:45am and 7:00am on April 30th. On that day, A4758 came online at 6:45am, and A4757 came online at 7:00am. His display loaded a recent image for A4757 but not A4758.

This is odd, because cameras obviously load when the user loads a display in the middle of the day. Cameras now seem to load if the user loads a display before the cameras come online. So there shouldn't be a case where they do not load.

My first inclination is that it has something to do with webDisplay receiving that first camera image sent by the camera. However, even if that was the case, it still should be able to pick up subsequent images. Meaning that A4758 should have, at the very least, updated at 7:00am or 7:15am.

Otherwise it could be an issue with the subscriptions object on load, but I have not seen any problems with that.

I will schedule the accounting computer to start up at 6:50am tomorrow to see if I can reproduce the situation.

Cdetviler commented 8 years ago

Jim reported that both cameras loaded at 7:00 this morning and both cameras started showing a current image on his display.

I had the accounting computer scheduled to wake up at at 6:55am and it too displayed both images on all three browsers. It would seem that this issue is fixed. I am going to continue to try testing this on the weekends on my personal laptop to see if I can reproduce the case mentioned in the above comment.