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

Companion is always at [medium] in about:performance in Firefox #721

Closed
autonome opened this issue May 17, 2019 · 9 comments
Closed

Companion is always at [medium] in about:performance in Firefox #721

autonome opened this issue May 17, 2019 · 9 comments
Labels
area/firefox Issues related to Mozilla Firefox

Comments

@autonome
Copy link

Screen Shot 2019-05-17 at 2 23 58 PM

@lidel lidel added area/firefox Issues related to Mozilla Firefox UX labels May 19, 2019
@lidel
Copy link
Member

lidel commented May 19, 2019

Thank you for noticing this.
I made a quick check and it is caused by setInterval running in the background page.

Companion is polling IPFS API every 3 seconds to refresh the peer count displayed on browser action badge and detect IPFS node going online/offline. IIRC we use setInterval instead of browser.alarms because Chrome hardcoded min interval to be 1 minute.

We could increase IPFS API poll interval but it would impact UX around online/offline detection.

Potential mitigation:

  • Remove peer count from browser badge to hide the fact we refresh state
    • been thinking about it anyway, peer count is just a vanity number without practical value. what is actually important is the icon color (aqua == online, grey == offline).
  • Pick bigger polling interval (10s? 30s?) in 'idle' mode (when browser action UI is hidden)
  • Poll API every 2s when browser action UI is visible

Thoughts?

@autonome
Copy link
Author

autonome commented May 20, 2019 via email

@lidel
Copy link
Member

lidel commented May 20, 2019

It is an indicator of connectivity health:

  • 0 - no peers, means we are still connecting to the swarm or that there is a network issue
  • > 0 - number of connected peers, mostly a vanity number
    (the goal of adding it to browser action badge was to highlight participation in p2p network)
  • -1 - internal value (never shown in UI) indicating API is offline (ipfs icon and UI is greyed out)

User does not do much with this, but IPFS Companion makes various decisions based on peering state. Peer count >= 0 means API is online, which in turn enables features that require access to API (quick upload) or Gateway ("Automatic Mode" enables/disables redirect to local node based on connectivity state).

@autonome
Copy link
Author

autonome commented May 21, 2019 via email

@lidel
Copy link
Member

lidel commented May 22, 2019

I've been thinking about "triggering peer update when any part of Companion is interacted with" and we may be able to make it pretty "lazy":

  • remove peer count from badge
    • (ux decision)
      add unique icons for -1 and 0 states
      OR
      repurpose browser action icon to indicate if current page is hosted on IPFS
  • keep a timestamp of the last peer count check
  • poll 'close realtime' (eg. every 3s) when browser action or other part of UI that requires API is open
  • stop polling when mentioned UIs are hidden (or do it once a minute+ via alarm)
  • use requests for IPFS resources as hints to do the API availability check
    • when IPFS resource is detected in web​Request​.onBefore​Request check if timestamp of last refresh is within some threshold before deciding if request should be redirected to local gateway
      • if peer count value is too old, perform peer count update
  • respect IdleState from browser.idle (we already run update only in active state, but we could decrease default idle threshold from 60s to a lower value)

Does it sound sensible?

@autonome
Copy link
Author

Nice to have: Some instrumentation so we can check different before/after these changes.

@olizilla
Copy link
Member

Here because I just hit the same issue.

Screenshot 2019-07-10 at 10 01 53

Of note, I'm seeing this with "all ipfs integrations" set to off.

I'm a big plus 1 of removing the peer count from the badge. I think we should generally reduce the prominence of how many peers you are connected to; it's doesn't tell you if you're going to have a good time finding the content you want. Zero peers means you are going to have a bad time, so we could special case that, but... for companion, I think it's way more interesting to focus the badge on "hey! this page comes in IPFS flavour", when we lazily check for a dnslink after letting the http request have a go... #710

@lidel
Copy link
Member

lidel commented Apr 20, 2020

Related: Firefox 76 will ship with a new profiler marker to include information about the webRequest blocking handlers registered by extensions (Bug 1625006).

@lidel
Copy link
Member

lidel commented Apr 12, 2024

This seems to no longer be the case since we switched to Manifest V3 (#666).

If you see perf. issues with 3.x version, please open new issue.

@lidel lidel closed this as completed Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/firefox Issues related to Mozilla Firefox
Projects
No open projects
Status: Needs Grooming
Development

No branches or pull requests

4 participants