Skip to content

♻️✅ Simplify rotate-to-fullscreen/integration test combo#15480

Merged
alanorozco merged 9 commits intoampproject:masterfrom
alanorozco:r8ion
May 23, 2018
Merged

♻️✅ Simplify rotate-to-fullscreen/integration test combo#15480
alanorozco merged 9 commits intoampproject:masterfrom
alanorozco:r8ion

Conversation

@alanorozco
Copy link
Copy Markdown
Member

@alanorozco alanorozco commented May 22, 2018

Partial for #9055.

This was originally only an integration test PR, but after much trying to deflake, I realized I had to change strategies:

  • Simplifies by no longer keeping track of visible videos. This was an unnecessary optimization, since:

    1. the sort operation should already be fast
    2. the number of videos in a document should be "small" (given device restrictions, etc.)
    3. the number of videos with the attribute set should even be smaller.
  • Sorts videos on all relevant signals (user interacted, play, etc.). Scroll shouldn't be a necessary signal, as manual playback is more relevant. Since the amount of videos should be small, and this happens only on relevant events, a linear search to filter before sort should be ok.

  • Adds integration test.

  • Cleans up the sort method somewhat.

Overall this is less code, has fewer failure points and is better tested.

});
removeElement(animation);
removeElement(mask);
video.signals().signal(VideoServiceSignals.USER_INTERACTED);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this method needs to listen to USER_INTERACTED instead of firing it (and having click handlers above fire it).

This event will be helpful for #9055 where we want AMP actions such as play(), pause() to be considered user-interactions which then we can easily do by triggering this event ( so maybe move the event definition to where other events like PLAYING, etc.. are in video-interface?)

Copy link
Copy Markdown
Member Author

@alanorozco alanorozco May 22, 2018

Choose a reason for hiding this comment

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

Welp, the signal is permanent, so the state would be the same regardless as to where the actual event is handled. I propose removing userInteractedWithAutoplay in favor of the signal (signals.get(USER_INTERACTED)), which should reconcile #9055.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see what you mean about triggering on other actions, though. Changes to this flow coming in a separate PR :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess I am suggesting that we want to call this method ( that hides he EQ icon, etc.. ) when the signal is received rather than having it fire it. To fix #9055, we would need registerCommonActions_ to also fire this signal but then this method won't run unless it listens to it (we would want this method to run for #9055)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup, on the same page!

if (this.isPlaying_
&& this.playCalledByAutoplay_
&& !this.userInteractedWithAutoPlay_) {
&& !this.userInteractedWithAutoPlay()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename to userInteracted() ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

});
removeElement(animation);
removeElement(mask);
video.signals().signal(VideoServiceSignals.USER_INTERACTED);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess I am suggesting that we want to call this method ( that hides he EQ icon, etc.. ) when the signal is received rather than having it fire it. To fix #9055, we would need registerCommonActions_ to also fire this signal but then this method won't run unless it listens to it (we would want this method to run for #9055)

@alanorozco alanorozco force-pushed the r8ion branch 2 times, most recently from 3b75547 to 13a94f7 Compare May 23, 2018 00:10
@alanorozco
Copy link
Copy Markdown
Member Author

Test is failing on Travis and I haven't been able to repro locally. Skipping for now, #15511

@alanorozco alanorozco merged commit 954fc21 into ampproject:master May 23, 2018
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.

3 participants