citp / news-disinformation-study

A research project on how web users consume, are exposed to, and share news online.
8 stars 2 forks source link

Fix attention tracking on page load #1

Closed jonathanmayer closed 4 years ago

jonathanmayer commented 4 years ago

We don't seem to always start a new attention span when a page loads.

jonathanmayer commented 4 years ago

The issue was an asynchronous await during the Navigation module page visit start handler. Since the page visit wasn't always recorded before the page attention start handler fired, we weren't consistently starting a new attention span. Fixed in e4bbfed2e3f6dd486a1c077acfcccd7876abce73, along with a linter error for the Storage module (looks like the linter doesn't support class defaults yet).

akohlbre commented 4 years ago

Still getting the "WebScience.Studies.Navigation: Warning: unexpected page attention stop" error, likely related to the note at the top of https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/onFocusChanged (apparently "some Linux window managers" includes i3wm). Discussed with Jonathan, possible fix is to have a global queue of events so that async events that rely on each other will run sequentially.

jonathanmayer commented 4 years ago

This bug should be conclusively squashed with https://github.com/citp/web-science/commit/4464f30d5ef882bc981c974853f4f756ddc65fc6. I implemented a window state cache in the PageEvents module, which allows synchronous listeners for windows, tabs, and idle events. That should avoid the unexpected state transitions that we'd previously encountered, where an asynchronous listener hadn't fully executed before another listener fired.