Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should tabs.Tab.lastAccessed be optional? #713

Open
oliverdunk opened this issue Oct 28, 2024 · 7 comments
Open

Should tabs.Tab.lastAccessed be optional? #713

oliverdunk opened this issue Oct 28, 2024 · 7 comments
Labels
needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time

Comments

@oliverdunk
Copy link
Member

oliverdunk commented Oct 28, 2024

In Chrome Canary 132.0.6800.1 and Firefox Nightly 133.0a1 (2024-10-27), tabs.Tab.lastAccessed is always set:

  • If the tab has never been accessed, it is set to the time the tab was created.
  • Otherwise, the last access time is used.

Firefox (and previously Chrome) marks this field as optional. Following a recent CL, this is no longer marked as optional in Chrome. It is not currently supported in Safari.

It would be great to decide between marking this as optional and having it be optional in practice, or documenting this as non-optional if all browsers want to continue setting it during tab creation.

Chromium bug: https://issues.chromium.org/375711376

@github-actions github-actions bot added needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time labels Oct 28, 2024
@tophf
Copy link

tophf commented Oct 28, 2024

if all browsers want to continue setting it during tab creation

Why would anyone want that? The new behavior doesn't match the name and judging by the comments in the "recent CL" the change in behavior wasn't based on an investigation how extensions are using this property.

@oliverdunk
Copy link
Member Author

Why would anyone want that?

I believe Firefox has been setting this on tab creation for a long time. While it is marked as optional, it's possible developers are relying on that behavior.

@tophf
Copy link

tophf commented Oct 28, 2024

It sounds wrong and that's not what I see in Firefox source code:

When the tab was created this session but hasn't been seen by the user, default to the application start time.

Where "application" means Firefox. Now this behavior actually does make sense, unlike Chromium's.

@dotproto
Copy link
Member

dotproto commented Oct 28, 2024

While the lastAccessed field is marked as optional in Firefox's tabs API schema, to my eye it looks like our implementation always exposes a value to extensions.

The lastAccessed property exposed to extensions maps to the lastAccessed getter on the MozTabbrowserTab class, which is the browser's internal tab class. In turn, that property maps to an internal _lastAccessed property on the same class. It looks like Firefox sets _lastAccessed on initialization to Date.now() or Infinity (meaning the tab is currently active).

@tophf, the logic you linked is for the lastSeenActive property on MozTabbrowserTab. Can you explain why you feel returning the application start time for a tab that has not been accessed makes more sense than the tab's creation time?

@tophf
Copy link

tophf commented Oct 28, 2024

It's about the intent expressed in the name of the property and how the property is used, which becomes important in this particular case when the tab is opened in background, which is an action indicative of the user's intent to "access this tab later", i.e. the tab definitely wasn't yet accessed, so Chromium's new behavior isn't helpful. Same for Firefox. Arguably the correct solution would be to account for this particular case explicitly by returning 0 or null or make the property optional.

@tophf
Copy link

tophf commented Oct 28, 2024

I see, I've linked the wrong part of the code (lastSeenActive), which means Firefox always behaved incorrectly in this case (opening of an inactive tab) just like Chromium behaves now, while Chromium behaved correctly for a while. I've edited my previous comment accordingly.

@hanguokai
Copy link
Member

This is a confusing and ill-defined property. Before discussing whether it should be optional, we should discuss what it should be, rather than how it is currently implemented.

There are some related concepts here, such as creation time, last interaction time, last visible time, tab switching, window switching, and page navigation.

For a multi-tabs window

  • when a tab was created in background, the user has not yet interacted with the page. Is this considered accessed?
  • when a tab was activated from other tabs, and stayed for 10 minutes. Was the last access time 10 minutes ago or now?
  • whether to consider user interactions, such as clicks, scrolling, and input?
  • when the tab is active, but the window is not visible to the user. Should this be considered as the user not accessing the tab?
  • when to update the last access time: page navigation, user interaction, pages become invisible, windows lose focus, or other?

For a single-tab window or popup window

  • the tab is always active (no other tabs in the window), but the user may not be accessing it (the window is not focused), even if it is visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time
Projects
None yet
Development

No branches or pull requests

4 participants