KEMBAR78
timeseries: improve card observer visibility logic with element ids by psybuzz · Pull Request #5234 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@psybuzz
Copy link
Contributor

@psybuzz psybuzz commented Aug 12, 2021

The Time Series dashboard has been under the assumption that getVisibleCardIds
accurately returns the set of CardIds that are within the visible viewport.

This assumption, backed by the CardObserver using an IntersectionObserver, is
false in an event sequence involving the same CardId twice:

  • domElementA with cardId1 is shown
  • domElementB with cardId1 is hidden

The Ngrx store is misled to believe that cardId1 is hidden, even though
domElementA may still be visible. This change corrects the CardObserver to
track unique DOM Elements.

The symptom is flaky and hard to consistently reproduce. Manually tested by
patching in https://github.com/psybuzz/tensorboard/tree/persist-tag for tagFilter
persistence in the URL, opened URLs with "?tagFilter=accuracy" that cause the
bad behavior more consistently, and observed that they no longer occur.

Googlers, see b/179450711.

@google-cla google-cla bot added the cla: yes label Aug 12, 2021
@psybuzz psybuzz marked this pull request as ready for review August 12, 2021 16:35
@psybuzz psybuzz requested a review from stephanwlee August 12, 2021 16:35
Comment on lines 188 to 189
elementToCardIdMap.set(element, this.cardId);
elementIdMap.set(element, nextElementId());
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of two different Map, consider using a data structure like {elementId: string; cardId: string} then reading it would be much more easier. Logically, when cardId is null, elementId should never be null and as currently typed, this is hard to guarantee.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

/**
* An opaque id intended to refer to exactly one specific DOM Element.
*/
export type ElementId = number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will not mention this more but consider using Symbol if you want it to be opaque and want to be able to do !elementId to check nullness instead of elementId ?? null which weakly leaks the fact that ElementId is a number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done as Symbol.

Still using an incrementing number inside the symbol, so that when printed in the console, it's easier to glance at things like:
entered [Symbol(1), Symbol(2)], exited [Symbol(3)]

Copy link
Contributor Author

@psybuzz psybuzz left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

Comment on lines 188 to 189
elementToCardIdMap.set(element, this.cardId);
elementIdMap.set(element, nextElementId());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

/**
* An opaque id intended to refer to exactly one specific DOM Element.
*/
export type ElementId = number;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done as Symbol.

Still using an incrementing number inside the symbol, so that when printed in the console, it's easier to glance at things like:
entered [Symbol(1), Symbol(2)], exited [Symbol(3)]

@psybuzz psybuzz merged commit d1b4cd9 into tensorflow:master Aug 12, 2021
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
…ensorflow#5234)

The Time Series dashboard has been under the assumption that `getVisibleCardIds`
accurately returns the set of CardIds that are within the visible viewport.

This assumption, backed by the CardObserver using an IntersectionObserver, is
false in an event sequence involving the same CardId twice:
- domElementA with cardId1 is shown
- domElementB with cardId1 is hidden

The Ngrx store is misled to believe that cardId1 is hidden, even though
domElementA may still be visible.  This change corrects the CardObserver to
track unique DOM Elements.

The symptom is flaky and hard to consistently reproduce.  Manually tested by
patching in https://github.com/psybuzz/tensorboard/tree/persist-tag for tagFilter
persistence in the URL, opened URLs with "?tagFilter=accuracy" that cause the
bad behavior more consistently, and observed that they no longer occur.

Googlers, see b/179450711.
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
…ensorflow#5234)

The Time Series dashboard has been under the assumption that `getVisibleCardIds`
accurately returns the set of CardIds that are within the visible viewport.

This assumption, backed by the CardObserver using an IntersectionObserver, is
false in an event sequence involving the same CardId twice:
- domElementA with cardId1 is shown
- domElementB with cardId1 is hidden

The Ngrx store is misled to believe that cardId1 is hidden, even though
domElementA may still be visible.  This change corrects the CardObserver to
track unique DOM Elements.

The symptom is flaky and hard to consistently reproduce.  Manually tested by
patching in https://github.com/psybuzz/tensorboard/tree/persist-tag for tagFilter
persistence in the URL, opened URLs with "?tagFilter=accuracy" that cause the
bad behavior more consistently, and observed that they no longer occur.

Googlers, see b/179450711.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants