Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix RM not updating if RR event unpaginated #874

Merged
merged 9 commits into from
May 11, 2017

Conversation

lukebarnard1
Copy link
Contributor

@lukebarnard1 lukebarnard1 commented May 9, 2017

If the RR event has been unpaginated, the logic in sendReadReceipt will now fallback on the event ID of the RM which in theory is always =< RR event ID stream-wise.

Also add some logging to debug RM bugs.

If the RR event has been unpaginated, the logic in `sendReadReceipt` will now fallback on the event ID of the RM which in theory is always =< RR event ID stream-wise.
@@ -575,7 +575,7 @@ module.exports = React.createClass({
var boundingRect = node.getBoundingClientRect();
var scrollDelta = boundingRect.bottom + pixelOffset - wrapperRect.bottom;

debuglog("ScrollPanel: scrolling to token '" + scrollToken + "'+" +
console.log("ScrollPanel: scrolling to token '" + scrollToken + "'+" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

@@ -523,6 +525,7 @@ var TimelinePanel = React.createClass({
// RRs) - but that is a bit of a niche case. It will sort itself out when
// the user eventually hits the live timeline.
//
console.log(currentReadUpToEventId, currentReadUpToEventIndex, this._timelineWindow.canPaginate(EventTimeline.FORWARDS));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

@@ -544,6 +547,11 @@ var TimelinePanel = React.createClass({
this.last_rr_sent_event_id = lastReadEvent.getId();
this.last_rm_sent_event_id = this.state.readMarkerEventId;

console.log('TimelinePanel: Sending Read Markers for ',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unconvinced this is the right thing to do. In particular there is a comment saying that we don't want to send out RRs if we don't know what we're doing. Why can't you just leave the RR alone rather than sending an old one?

@@ -510,8 +510,10 @@ var TimelinePanel = React.createClass({
var currentReadUpToEventId = this._getCurrentReadReceipt(true);
var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId);

currentReadUpToEventIndex = currentReadUpToEventIndex ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a comment to explain what we're doing.

Isn't zero a valid index? why do we fall back in that case?

@lukebarnard1
Copy link
Contributor Author

Why can't you just leave the RR alone rather than sending an old one?

This is a fair point. I'll rewrite this to be a bit more stable and to accommodate RMs more sensibly.

Any suggestions as to how to log things that I'd like to include in the logs are welcome.

@richvdh
Copy link
Member

richvdh commented May 9, 2017

Any suggestions as to how to log things that I'd like to include in the logs are welcome.

If you really want to include them in the rageshakes, then console.log it is. But do we really need to be this verbose? Could you use debuglog and set DEBUG=1 when investigating a problem?

@lukebarnard1
Copy link
Contributor Author

Could you use debuglog and set DEBUG=1 when investigating a problem?

That's largely what I have been doing but this is subtle enough to be very difficult to reproduce when someone sends a rageshake about one particular instance of the RM not updating. TBH if I rewrite sendReadReceipt the logs will hopefully become redundant. I'll remove them in the process of rewriting.

Instead of modifying the condition for updating the RR, separate the RM and RR conditions and use an OR to decide when to set both.

Make some logs only log when DEBUG.
if (!cli || cli.isGuest()) return;

let shouldSendRR = true;

var currentReadUpToEventId = this._getCurrentReadReceipt(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be worth renaming these as 'read receipt' for consistency with the rest of the function - I'm finding it horribly confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure


var lastReadEvent = this.state.events[lastReadEventIndex];
shouldSendRR = shouldSendRR &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could do with a comment: "only send a RR if ..."

this.last_rr_sent_event_id != lastReadEvent.getId()) ||
this.last_rm_sent_event_id != this.state.readMarkerEventId) {

if (shouldSendRR || shouldSendRM) {
this.last_rr_sent_event_id = lastReadEvent.getId();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's possible for lastReadEvent to be undefined here (eg if lastReadEventIndex was null), which would make this blow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now protected by shouldSendReadReceipt which is set to false if the index is null.

this.last_rr_sent_event_id != lastReadEvent.getId()) ||
this.last_rm_sent_event_id != this.state.readMarkerEventId) {

if (shouldSendRR || shouldSendRM) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely if we've decided not to send a RR, then we, uh, shouldn't send a RR even if shouldSendRM is true?

(in other words: pass null in the call to setRoomReadMarkers and don't update last_rr_sent_event_id)

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh May 10, 2017
@lukebarnard1 lukebarnard1 assigned richvdh and unassigned lukebarnard1 May 10, 2017
@@ -177,8 +177,8 @@ var TimelinePanel = React.createClass({
componentWillMount: function() {
debuglog("TimelinePanel: mounting");

this.last_rr_sent_event_id = undefined;
this.last_rm_sent_event_id = undefined;
this.lastRRSentSentId = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Sent/Event
(and throughout)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops!


const currentReadUpToEventId = this._getCurrentReadReceipt(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought you were going to rename these :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, I understood something else and agree they should be consistent

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh May 10, 2017
Luke Barnard added 2 commits May 11, 2017 09:20
`ReadUpTo` -> `RR`
`ReadReceipt` -> `RR`
`ReadMarker` -> `RM`
@lukebarnard1 lukebarnard1 assigned richvdh and unassigned lukebarnard1 May 11, 2017
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm I think

@richvdh richvdh assigned lukebarnard1 and unassigned richvdh May 11, 2017
@lukebarnard1 lukebarnard1 merged commit 2437eb7 into develop May 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants