Closed Bug 1595197 Opened 5 years ago Closed 4 years ago

webRequest.StreamFilter.onstop is being called twice

Categories

(WebExtensions :: Request Handling, defect, P1)

72 Branch
defect

Tracking

(firefox-esr68 unaffected, firefox70 unaffected, firefox71 unaffected, firefox72 wontfix, firefox73 wontfix, firefox75 wontfix, firefox76 wontfix, firefox77 fixed)

RESOLVED FIXED
mozilla77
Tracking Status
firefox-esr68 --- unaffected
firefox70 --- unaffected
firefox71 --- unaffected
firefox72 --- wontfix
firefox73 --- wontfix
firefox75 --- wontfix
firefox76 --- wontfix
firefox77 --- fixed

People

(Reporter: particlecore, Assigned: mixedpuppy)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(2 files)

Attached file test.zip

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0

Steps to reproduce:

Bug discovered in Nightly 72.0a1 (2019-11-08) (64-bit)

Load attached demo extension

Click "Inspect" and switch to the console

Open www.youtube.com

Actual results:

The console outputs two messages confirming the .onStop function is now being called twice:

19:59:45.916
This message should only show once in the console 0.27884815437952426 background.js:21:21
19:59:45.982
This message should only show once in the console 0.2947613163421413

Expected results:

The console should only output once, the onstop function should only be called once.

This appears to be related to a fix for this (these) issue(s)

1587960
1590898

Product: Firefox → WebExtensions
Component: Untriaged → Request Handling

onstart also fires 2 times.

Flags: needinfo?(perry)

This is what the console gives:
onstart 2 times
ondata 120 times
onstop
ondata
onstop

(In reply to kernp25 from comment #2)

This is what the console gives:
onstart 2 times
ondata 120 times
onstop
ondata
onstop

ondata looks normal at a glance because it is called repeatedly until there is no more data, however I can't tell if it is being called more times than it should without comparing the behavior with ondata before this problem surfaced.

Component: Request Handling → Untriaged
Product: WebExtensions → Firefox

Can you confirme this bug?

Flags: needinfo?(hani.yacoub)

Hi, particlecore,

Thanks for your contribution!

I'm adding product and component on this, I think you are right and it could be related to the fixes for 1587960 / 1590898.

Regards,

Component: Untriaged → Request Handling
Product: Firefox → WebExtensions

I think the problem may be that we're calling WebRequest callbacks for internal redirects (on top of the initial request), leading to these duplicate calls. Internal redirects shouldn't be observable by web pages (they're "internal" by nature).

Flags: needinfo?(perry)
Flags: needinfo?(hani.yacoub)
Assignee: nobody → perry

Hello,

I have managed to reproduce the issue based on the provided STR only on the latest Nightly (72.0a1/20191114055112) under Windows 10 Pro 64-bit and MacOS Catalina 10.15.

The latest Beta (71.0b9/20191111170815) and Release (70.0.1/20191030021342) are unaffected by this.

The .onStop function is indeed being called twice and the console outputs 2 messages to confirm that.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Bugbug thinks this bug is a regression, but please revert this change in case of error.

Keywords: regression

Each subtest (i.e. each call to call{XHR,Fetch}) will ensure that
StreamListener.on{start,stop} is called once and only once. If either are called
more than once before the next subtest, the overall test will fail.

(In reply to Perry Jiang [:perry] from comment #6)

I think the problem may be that we're calling WebRequest callbacks for internal redirects (on top of the initial request), leading to these duplicate calls. Internal redirects shouldn't be observable by web pages (they're "internal" by nature).

Seems to be something to do with cache. If I open the page fresh (meaning no cache in browser) the issue does not occur. Once I open it again and every next time it finds in cache the issue occurs.

I did this:

  • Open the page for the first time (no cache in browser) issue does not occur
  • Open the same page after the first time (cache is turned on in the browser by the way) issue occurs all the time
  • Press Ctrl + Shift + R on the same page (to force full reload) issue does not occur

This might also be linked with the issue of Firefox leaking cached content/resources directly to the filter as it was reported before, I found these in the following search results for an issue I also faced and ultimately I had to do the same thing the users did (remove the initial content):

(In reply to particlecore from comment #10)

I did this:

  • Open the page for the first time (no cache in browser) issue does not occur

No cache presumably means all site data cleared which means no ServiceWorkers are present. On first load, a ServiceWorker won't be present for initial navigation. (Although it can start controlling the page via https://developer.mozilla.org/en-US/docs/Web/API/Clients/claim.)

  • Open the same page after the first time (cache is turned on in the browser by the way) issue occurs all the time

The ServiceWorker should be present at this time.

  • Press Ctrl + Shift + R on the same page (to force full reload) issue does not occur

This bypasses ServiceWorkers as well as the cache.

Do we need kmag's signoff here? He's busy with fission.

The priority flag is not set for this bug.
:jimm, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jmathies)
Flags: needinfo?(jmathies)
Priority: -- → P3

Perry, what is the status of the work on this?

Flags: needinfo?(perry)

Sorry, got caught up on some other stuff and was OOO for a few days. I'm working on this right now.

Flags: needinfo?(perry)

This will likely miss 73 but we could still take a patch in 74 next week.

Still not fixed in 74

As a result of this bug I've had to implement a workaround because all users of my extension could no longer load YouTube pages since this duplicate event dispatch bug was resulting in out of memory errors.
Details in https://github.com/ParticleCore/Iridium/issues/825

Blocks: 1626831
Assignee: perry → mixedpuppy
Priority: P3 → P1
Attachment #9109026 - Attachment description: Bug 1595197 - don't fire WebRequest observer callbacks for internal redirects r?kmag,asuth → Bug 1595197 - fix StreamFilter redirect handling
Blocks: 1631587
No longer blocks: 1631587

A bisect was done in one of the duplicates, so we should mark Regressed by bug 1590898.

(In reply to Rob Wu [:robwu] from comment #1)

I bisected. This was regressed by bug 1590898 (https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=ff0b109afd62c3c2dd396463bb3632228e959ff3&tochange=a4c51f3f0bb1dd51ded827d3049d633f56662a7f)

Pushed by scaraveo@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fca6b4827fc6
fix StreamFilter redirect handling r=zombie,robwu
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: