Opened 3 years ago

Closed 3 years ago

#1947 closed Bug (fixed)

Live! real time reorders last visitors on display

Reported by: matt Owned by:
Priority: major Milestone: Future releases
Component: Core Keywords:
Cc: Sensitive: no

Description

Live! real time widget is somehow reordering visitors before display. This could happen at the JS level, as it seems the returned HTML is in the right order.

I see for example in the returned HTML

  • Wed 5 Jan - 12:33:34 (0s)
  • Wed 5 Jan - 12:33:27 (0s)
  • Wed 5 Jan - 12:33:14 (0s)

But the widget on refresh, fed this HTML, will display

  • Wed 5 Jan - 12:33:14 (0s)
  • Wed 5 Jan - 12:33:27 (0s)
  • Wed 5 Jan - 12:33:34 (0s)


Also it gives the illusion that there are new visits since it refreshes with the visual effect, but in fact there hasn't been any new visitor.

Maybe we should rewrite the Live plugin once and for all to fix existing issues:

  • this issue with random order and wrong refresh
  • 3 http requests but it should only make one
  • do not send more requests when previous ones didn't arrive #1662
  • also I noticed that when the Live! is active and the plugin is shut down, the widget refreshes with bogus data. Instead, if plugin returns error, it should not update the last visitors display and display the returned error at the top of the widget.

The new rewrite could read JSON from the API and write the HTML directly, this would simplify the code.

Attachments (2)

spy.js.patch (570 bytes) - added by halfdan 3 years ago.
many requests.PNG (62.1 KB) - added by matt 3 years ago.
many requests triggered

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by halfdan

I suspect that this is a race condition with slow requests. There is a mechanism to stop ajax request once their result is being parsed, but this does not stop ajax requests being sent when the results hasn't arrived yet (due to slow requests). I prepared a small patch for spy.js - can you check if this fixes the issue? (The issue arrises when two requests return almost at the same time and spy.js is inserting the live visitors item by item)

Changed 3 years ago by halfdan

comment:2 Changed 3 years ago by matt (mattab)

(In [3624]) Refs #1947 Fixes (?) reordering problem. Kuddos halfdan
Does it also block subsequent http requests until the previous ones have been fetched?

comment:3 Changed 3 years ago by matt (mattab)

yes it blocks all subsequent http requests, nice!

comment:4 Changed 3 years ago by matt (mattab)

Sorry I'm spamming, but to answer myself, no it doesn't appear to block all subsequent requests.

To replicate:

  • open Live
  • in Live/API.php add
    $i =0;
    		while($i<10000000) $i++; }
    
    just after
    private function loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes = 0, $days = 0, $type = false )
    	{
    
  • Then let Live! running for few minutes.
  • See screenshot, it started 9 requests at the same time on the server.

Changed 3 years ago by matt (mattab)

many requests triggered

comment:5 Changed 3 years ago by matt (mattab)

(In [3628]) Refs #1947 - displays last page view time instead of first page time

comment:6 Changed 3 years ago by matt (mattab)

  • Milestone changed from 1.2 Piwik 1.2 to Feature requests

Decreasing priority. We have had this bug for too long, but I have the feeling the final fix will involve rewriting the thing to use Json. If someone is keen or has a patch please comment here

comment:7 Changed 3 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [3922]) Fixes #2054, #2076, #1947

  • Visitor Log: offset now removed from Live API all together. As a result, Previous< in the datatable footer will return to the start, this could be improved but OK for now. Offset for next is the ID Visit as before
  • Live! widget: offset is now the timestamp, so the request hits the INDEX
  • This should fix most of the reordering bug: well now it should load on the top, the visits that have been updated since last refresh, and it deletes previous visit rows that are being updated
Note: See TracTickets for help on using tickets.