filterResponseData from the WebRequest API returns script bytecode cache data
Categories
(WebExtensions :: Request Handling, defect, P2)
Tracking
(firefox-esr68 wontfix, firefox73 wontfix, firefox74 wontfix, firefox75 wontfix, firefox76 wontfix, firefox77 fixed)
People
(Reporter: cgemici, Assigned: mixedpuppy)
References
Details
(Keywords: dev-doc-complete, regression)
Attachments
(9 files, 2 obsolete files)
5.13 MB,
image/gif
|
Details | |
864 bytes,
application/x-zip-compressed
|
Details | |
9.92 MB,
image/gif
|
Details | |
1.00 KB,
application/x-zip-compressed
|
Details | |
1.01 KB,
application/x-xpinstall
|
Details | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
Steps to reproduce:
Noticed this while trying to write a separate extension that needed to read the page response from an extension but the issue can be reproduced with the example at https://github.com/mdn/webextensions-examples/tree/master/http-response
In background.js, to see the problem you can add something like console.log(details.url, str) inside the ondata handler.
In line 20 change the url to the site you want to test this with and the types to ["main_frame", "script"]
Add permissions to the site being used inside manifest.json
When you go to a website, like mozilla.org, the main_frame response will display correctly but some of the scripts seem to contain illegible characters instead. (The first on mozilla was https://www.mozilla.org/media/js/BUNDLES/site.ec263d31b78e.js )
If you open the directly with the url it gets displayed correctly.
Actual results:
When trying to get the response string using the filterResponseData function the response sometimes comes out garbled for script (and potentially other types) but when it works withot any problem for main_frame type requests. Based on some of the comments in https://bugzilla.mozilla.org/show_bug.cgi?id=1255894 I suspect I'm getting the gzipped response.
Expected results:
I should be able to get the response text for any page that's being requested.
Updated•5 years ago
|
When trying to get the response string using the filterResponseData function the response sometimes comes out garbled for script
I also suffered from this problem. My guess is not about gzipped, but cached. There is nothing wrong when the script is not cached and download from streaming, but when the script is cached, the decoding attempt to filterResponseData will be failed. (This is tested by enabling the option "Disable cache")
Possibly related link (not filed in Bugzilla):
https://stackoverflow.com/questions/52128329/decode-string-from-typedarray-cached-data-passed-via-webrequest-filterresponseda
https://discourse.mozilla.org/t/filterresponsedata-bad-decoding-from-cached-file/31417
Comment 2•5 years ago
|
||
:mixedpuppy, could you help here ?
Assignee | ||
Comment 3•5 years ago
|
||
Just an FYI that I have tried looking into this, I have yet to make a clear STR for it. I'll continue on it soon.
Assignee | ||
Updated•5 years ago
|
Comment 4•5 years ago
|
||
This bug just broke embedded YouTube videos for users of the add-on Iridium (12k users) . At least that's what the developer of the add-on is suspecting.
Maybe this thread will help with reproducing what's happening:
https://github.com/ParticleCore/Iridium/issues/782
I have a workaround for this bug:
function listener(details) {
if (!details.url.includes("?")) {
return {
redirectUrl: details.url + "?" + details.requestId
};
}
else {
// not already handled?
if (!(details.url.includes("?" + details.requestId) ||
details.url.includes("&" + details.requestId))) {
return {
redirectUrl: details.url + "&" + details.requestId
};
}
}
let filter = browser.webRequest.filterResponseData(details.requestId);
let encoder = new TextEncoder();
let data = [];
filter.ondata = event => {
data.push(event.data);
};
filter.onstop = async event => {
let blob = new Blob(data, {type: 'text/javascript'});
let str = await blob.text();
console.log(details, str);
filter.write(encoder.encode(str));
filter.close();
};
}
browser.webRequest.onBeforeRequest.addListener(
listener,
{urls: ["<all_urls>"], types: ["script"]},
["blocking"]
);
It seems to work fine.
Comment 9•4 years ago
|
||
Hello @kernp25,
I managed to reproduce the bug you showed in the attached gif from Comment 6. The issue was reproduced on the latest Nightly (75.0a1/20200303214128), Beta (74.0/20200302184608), Release (73.0.1/20200217142647) under Windows 10 Pro 64-bit and MacOS Catalina 10.15.
As STR, I employed the following:
- Load the extension from Comment 7 in about:debugging
- Open the extension console (Inspect add-on in about:debugging→ Console)
- Open a new tab and access any webpage (for my attempts I used https://www.t-online.de/)
- Switch to the add-on console tab
Note: When first accessing the webpage (url was manually input in the url bar), all console output content is properly displayed. No illegible characters are displayed. - Right click the tab with the previously accessed webpage and reload the tab
- Notice that the console output is not correctly displayed, as it contains illegible characters
As per the suggestion from Comment 1, I have also disabled the cache by flipping the browser.cache.disk.enable
and browser.cache.memory.enable
prefs to false and attempted to reproduce the issue again. This time, console output was properly displayed each time.
Please let me know if there is something else I can assist you with.
Comment 10•4 years ago
|
||
Assignee | ||
Comment 11•4 years ago
|
||
@kernp25, what part of the workaround addresses the problem? Is it a redirection and you're tracking the request id to handle the filtering? Or is is something in the filtering itself?
Comment 12•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #11)
@kernp25, what part of the workaround addresses the problem? Is it a redirection and you're tracking the request id to handle the filtering? Or is is something in the filtering itself?
I'm just Bypassing the cache.
So the url is not cached before adding the filter.
Comment 13•4 years ago
|
||
(In reply to Alex Cornestean from comment #9)
Please let me know if there is something else I can assist you with.
Can you set the status of this bug to NEW?
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
Hello,
I’ve checked for a regression window (from 01.01.2018 up until the current date) and observed the following:
- builds from before the first half of May 2019 output the
TypeError: blob.text is not a function
error in the console while having the extension from Comment 7 installed and opening https://www.t-online.de/ . No other information is displayed in the console apart from that error. This appears to be correlated with Firefox APIs accepting Blob objects with FX69 (05.20.2019) - builds after May 2019 are all affected by the issue
Considering these, the issue does not seem to be a regression and will set it to New.
Comment 16•4 years ago
|
||
Bugbug thinks this bug is a regression, but please revert this change in case of error.
Updated•4 years ago
|
Comment 17•4 years ago
|
||
Shane, could we get an assignee to work on this one?
Assignee | ||
Comment 18•4 years ago
|
||
keeping my ni to look at again, but wontfix'ing for 75 since it's been a couple releases, and there is currently a work around.
Comment 19•4 years ago
|
||
I hope, it will be fixed in Firefox 76.
Assignee | ||
Comment 20•4 years ago
|
||
It looks like this should have been fixed by bug 1590898. Looking at the patch there, the test reflects exactly what is happening, but it doesn't test a cached request.
I researched this and am finding that it is always from the cache with a content encoding (I've seen "br" and "gzip").
I'm trying to write a test for this now since I understand what is happening, though it is proving somewhat elusive. Hopefully I'll have that today.
Assignee | ||
Comment 21•4 years ago
|
||
And I suspect the change in StreamFilterParent::OnStartRequest in https://phabricator.services.mozilla.com/D50898 is the culprit.
Comment 22•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #20)
It looks like this should have been fixed by bug 1590898. Looking at the patch there, the test reflects exactly what is happening, but it doesn't test a cached request.
I researched this and am finding that it is always from the cache with a content encoding (I've seen "br" and "gzip").
I'm trying to write a test for this now since I understand what is happening, though it is proving somewhat elusive. Hopefully I'll have that today.
Are you sure about the regressing bug? This bug has been around since way before bug 1583700 landed.
Assignee | ||
Comment 23•4 years ago
|
||
Assignee | ||
Comment 24•4 years ago
|
||
The test I've attached illustrates a script file with content encoding gzip, however, it is NOT failing. The manual STR does fail.
Assignee | ||
Comment 25•4 years ago
|
||
This is a modification on the prior addon that just makes it easier to see the failing requests along with the associated request data.
Comment 26•4 years ago
|
||
There is one more issue where filterResponseData fails after redirection (301, 302) - uBlock Origin issue tracker: https://github.com/uBlockOrigin/uBlock-issues/issues/942
Gorhill said:
The StreamObject created by uBO fires a Channel redirected error, and as a result uBO is unable to act on the stream data.
From what I see it works fine in 68.6.0esr and does not in 74.
I'm trying to bisect, but have problem - there is a range where it does not work at all on case with compressed response https://bit.ly/2Wqw7Ol
.
I will create new bug when I finish.
Comment 27•4 years ago
|
||
Assignee | ||
Comment 28•4 years ago
|
||
This one doesn't seem regressed by 1583700, it is definitely cache related.
Honza, the data we get in onDataAvailable seems to be corrupted or something, it is 100% reproducible, but I haven't figured out why. It is not related to a redirect. Any thoughts?
Comment 29•4 years ago
|
||
Old add-ons did this to read the data:
var binaryInputStream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
binaryInputStream.setInputStream(inputStream);
this.data += binaryInputStream.readBytes(count);
Comment 30•4 years ago
|
||
I tested it again using the code from here in browser console and the problem also exist here.
Comment 31•4 years ago
|
||
The code i used for testing in the browser console.
Assignee | ||
Comment 32•4 years ago
|
||
Ok, I've tracked this down to the bytecode cache. Specifically, if you turn off the pref dom.script_loader.bytecode_cache.enabled .
@kernp25, does this happen for anything other than script loads for you? Does flipping that pref fix the issue (it does for me)?
Some more selective logging led me to this.
nsHttpChannel::PreferAlternativeDataType type(javascript/moz-bytecode-20200325173538) contentType() altData(1)
console.log: "onHeadersRecieved for 252 creating filter\n"
console.log: "onHeadersRecieved for 252 creating filter\n"
HttpChannelParent::OnStartRequest [this=0x148aafc60, aRequest=0x1469fc040]
HttpBaseChannel::SetApplyConversion [this=0x1469fc000 id=188 value=0]
HttpBaseChannel::DoApplyContentConversions [this=0x1469fc000 id=188]
not applying conversion per mApplyConversion id=188
HttpChannelChild::OnStartRequest [this=0x18bfc2000 id=188 applyConversion=1]
HttpBaseChannel::SetApplyConversion [this=0x18bfc2030 is=188 value=1]
HttpBaseChannel::DoApplyContentConversions [this=0x18bfc2030 id=188]
not applying conversion because delivering alt-data
StreamFilterParent::OnDataAvailable
StreamFilterChild::EmitData
StreamFilter::FireDataEvent channelId(252)
console.log: "ondata for 252 [object ArrayBuffer]"
console.log: "ondata invalid chars for 252"
@valentine, in bug 1487100 you added the ability to get at the original input stream. I'm not certain that will help in this case, where we're using a stream filter. It seems like I need a way to signal for a channel to bypass the alt-data[1]. I'm not sure if there is a way to handle this just for the extension stream filters, allowing the byte cache to be used otherwise, or if there is a way to decode within our own OnDataAvailable handler[2].
[1] https://searchfox.org/mozilla-central/rev/4d9cd186767978a99dafe77eb536a9525980e118/netwerk/protocol/http/HttpBaseChannel.cpp#1182-1186
[2] https://searchfox.org/mozilla-central/rev/4d9cd186767978a99dafe77eb536a9525980e118/toolkit/components/extensions/webrequest/StreamFilterParent.cpp#604
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 33•4 years ago
|
||
@valentine, also is there any magic to making this happen for the test I attached?
Assignee | ||
Updated•4 years ago
|
Comment 34•4 years ago
|
||
Thanks for tracking this down. Seems a bit tricky indeed.
From what I can tell, we have 2 options here:
- Trying to clear the preferred alt-data types when there is a filter installed for the request.
I am not sure we can do that (depending on how filterResponseData works)- can we know if the filter is installed for a channel before calling async open / before onStartRequest ?
- Maybe we could use the original input stream - again, I'm not sure how the filter works - technically we could open the original input stream, ignore all the onDataAvailable calls, and just read from the stream and pass that forward.
Comment 35•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #32)
Does flipping that pref fix the issue (it does for me)?
When using the add-on from Comment 7 and flipping the pref it fixes the issue for me.
Assignee | ||
Comment 36•4 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #34)
Thanks for tracking this down. Seems a bit tricky indeed.
From what I can tell, we have 2 options here:
- Trying to clear the preferred alt-data types when there is a filter installed for the request.
I am not sure we can do that (depending on how filterResponseData works)
It implements nsIStreamListener. If there is a way to clear the alt-data types (only for the channel being attached to) I could do that just after successfully calling channel.setNewListener. This seems like it would be the cleanest way to deal with this (based on my thinking through my responses below).
- can we know if the filter is installed for a channel before calling async open / before onStartRequest ?
Not before asyncOpen, but certainly before onStartRequest since streamfilter implements that. What I see is that the alt-data input stream is opened prior to the response starting (webRequest.onHeadersReceived) but after http-on-modified (webRequest.onBeforeRequest). So relying on that would require extensions to implement their filter during onBeforeRequest. That may not be optimal for some situations.
In the case an extension creates the filter earl (onBeforeRequest) we could probably identify that an extension has a stremlistener attached and bypass alt-data for that request.
If we can somehow change the input stream prior to calling nsIStreamListener.onStartRequest, we could probably also do the same (detect that an extension has attached a streamlistener).
- Maybe we could use the original input stream - again, I'm not sure how the filter works - technically we could open the original input stream, ignore all the onDataAvailable calls, and just read from the stream and pass that forward.
DoApplyContentConversions is called right after StreamFilterParent::OnStartRequest, so we could conceivably bypass alt-data somehow during StreamFilterParent::OnStartRequest. Perhaps signal the channel to switch back to the original stream? As mentioned above, at this point the alt data stream is already opened.
Assignee | ||
Comment 37•4 years ago
•
|
||
Ok, I have a solution, though kinda hacky IMO.
We need to stop the block that decides to load alt-data[1]. I can do that by inserting the following before attaching our stream listener[2]. If I wait till later (when we call setNewListener) the cache decision has already won that race. Note that this also requires the extension to create the filter in onBeforeRequest, rather than onHeadersReceived. It seems to me that this could also be a performance hit (bypassing the bytecode cache).
// Disable alt-data for extension stream listeners.
nsCOMPtr<nsIHttpChannelInternal> internal = do_QueryInterface(chan);
internal->SetAltDataForChild(false);
[1] https://searchfox.org/mozilla-central/rev/b712398b7fae54ef377a558d6f16dede7a7f8530/netwerk/protocol/http/nsHttpChannel.cpp#5122-5132
[2] https://searchfox.org/mozilla-central/rev/b712398b7fae54ef377a558d6f16dede7a7f8530/toolkit/components/extensions/webrequest/StreamFilterParent.cpp#139
Comment 38•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #37)
Ok, I have a solution, though kinda hacky IMO.
We need to stop the block that decides to load alt-data[1]. I can do that by inserting the following before attaching our stream listener[2]. If I wait till later (when we call setNewListener) the cache decision has already won that race. Note that this also requires the extension to create the filter in onBeforeRequest, rather than onHeadersReceived. It seems to me that this could also be a performance hit (bypassing the bytecode cache).
Presumably there's no way of knowing if the filter will modify the response, and if that's the case, we definitely don't want to deliver alt-data.
Alt-data is already an optimization, so I am generally OK with this solution.
DoApplyContentConversions is called right after StreamFilterParent::OnStartRequest, so we could conceivably bypass alt-data somehow during StreamFilterParent::OnStartRequest. Perhaps signal the channel to switch back to the original stream? As mentioned above, at this point the alt data stream is already opened.
Switching back to the original stream would be technically possible, but I don't think it's possible to do from onStartRequest, since we've already started to read from the stream by them. Plus, if we want ContentConversions to happen, they would need to happen on the original content.
Assignee | ||
Comment 39•4 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #38)
(In reply to Shane Caraveo (:mixedpuppy) from comment #37)
Ok, I have a solution, though kinda hacky IMO.
We need to stop the block that decides to load alt-data[1]. I can do that by inserting the following before attaching our stream listener[2]. If I wait till later (when we call setNewListener) the cache decision has already won that race. Note that this also requires the extension to create the filter in onBeforeRequest, rather than onHeadersReceived. It seems to me that this could also be a performance hit (bypassing the bytecode cache).
Presumably there's no way of knowing if the filter will modify the response, and if that's the case, we definitely don't want to deliver alt-data.
Alt-data is already an optimization, so I am generally OK with this solution.
We do not have any way to know. So I think the solution here will generally be:
- SetAltDataForChild early
- determine what type we have, if it is alt data, disconnect StreamFilter and send an error to the extension.
- disconnect because we do not want an extension modifying any alt-data that gets used.
With the above, an extension can create the filter during onBeforeRequest if it wants/needs to modify cached scripts/etc that would use alt data. If it creates the filter later, we wont give the extension any of that data in the filter.
Comment 40•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #39)
With the above, an extension can create the filter during onBeforeRequest if it wants/needs to modify cached scripts/etc that would use alt data. If it creates the filter later, we wont give the extension any of that data in the filter.
I didn't know that was an option. That seems like a good plan! Let me know if you need any help with anything. Thanks!
Comment 41•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #39)
With the above, an extension can create the filter during onBeforeRequest if it wants/needs to modify cached scripts/etc that would use alt data. If it creates the filter later, we wont give the extension any of that data in the filter.
This needs also be documented on mdn?
Comment 42•4 years ago
|
||
uBlock Origin seems to use filterResponseData, so disabling the bytecode cache for everyone with that extension installed would be unfortunate.
Comment 43•4 years ago
|
||
(In reply to Tom Schuster [:evilpie] from comment #42)
uBlock Origin seems to use filterResponseData, so disabling the bytecode cache for everyone with that extension installed would be unfortunate.
Presumably this bug only applies to JS files, and only when they are loaded from the cache.
Maybe we could find a way to exclude all the others?
Assignee | ||
Comment 44•4 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #43)
(In reply to Tom Schuster [:evilpie] from comment #42)
uBlock Origin seems to use filterResponseData, so disabling the bytecode cache for everyone with that extension installed would be unfortunate.
Presumably this bug only applies to JS files, and only when they are loaded from the cache.
Maybe we could find a way to exclude all the others?
Actually, only when loaded from alt-data. js files loaded from cache (not alt-data) work just fine in the filter.
So far as disabling bytecode cache, I was already aware of the issue and considering what might be done for that.
Comment 45•4 years ago
|
||
(In reply to Tom Schuster [:evilpie] from comment #42)
uBlock Origin seems to use filterResponseData, so disabling the bytecode cache for everyone with that extension installed would be unfortunate.
uBO is using it only for main document. I think AdGuard is using it on any text response https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#replace-modifier
Comment 46•4 years ago
|
||
uBlock Origin does not seem to use filterResponseData with type script?
https://github.com/gorhill/uBlock/blob/98d7de0502d9ecb535e749b6112d9bb77499a1b3/src/js/traffic.js#L1046-L1052
https://github.com/gorhill/uBlock/blob/98d7de0502d9ecb535e749b6112d9bb77499a1b3/src/js/traffic.js#L1062
Comment 47•4 years ago
|
||
Okay very good. I didn't read the code carefully. We should maybe check if there is another popular extension that would break it.
Assignee | ||
Comment 48•4 years ago
|
||
It's not a matter of what uBO does, it's whether we want to make it possible to turn off the byte cache which could affect overall performance.
Right now I'm leaning towards simply throwing a filter.onerror so extensions can detect the situation, and so we avoid the potential for an extension to change the bytecache data.
Comment 49•4 years ago
|
||
With the above, an extension can create the filter during onBeforeRequest if it wants/needs to modify cached scripts/etc that would use alt data.
But this will still be possible?
Assignee | ||
Comment 50•4 years ago
|
||
(In reply to kernp25 from comment #49)
With the above, an extension can create the filter during onBeforeRequest if it wants/needs to modify cached scripts/etc that would use alt data.
But this will still be possible?
The point is whether that is something we actually want to allow, and whether we can actually make it work consistently. I'm going to add the error for now since it at least makes the situation better than it currently is.
Comment 51•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #48)
It's not a matter of what uBO does, it's whether we want to make it possible to turn off the byte cache which could affect overall performance.
It seems to me that if a request is going to be intercepted and maybe modified, then alt-data would be useless anyway, so we can just disable it in that case.
Comment 52•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #50)
The point is whether that is something we actually want to allow
This does not make sense!
If a add-on wants to read a cached js file, it can do so by using the bypass cache hack!
Comment 53•4 years ago
|
||
I'm not interested in the alt-data i just want to read the cached js file.
Assignee | ||
Comment 54•4 years ago
|
||
If the script byte cache is bypassing the normal http cache, we do not want to
offer the ability to an extension to change the cache data.
Assignee | ||
Comment 55•4 years ago
|
||
If an extension creates a stream filter early enough, we can
disable the use of the alt-data cache allowing the extension to properly
handle filtering.
Updated•4 years ago
|
Assignee | ||
Comment 56•4 years ago
|
||
I've yet to decide whether the 2nd patch is a good idea and will get an additional opinion on our team. In the meantime...
@valentin, if we disabled alt-data and an extension were to use a filter on all requests, it is essentially the same a flipping the pref. Are you certain that doesn't matter?
Comment 57•4 years ago
|
||
When using a listener with "<all_urls>", it is not great for performance anyway.
Comment 58•4 years ago
|
||
Sorry for OT, but speaking about performance, uBlock Origin is still injecting no-cache, no-store, must-revalidate
into cache-control
header value of all requests affected by filters which use filterResponseData
or modify CSP headers because of cache racing(?) - bug 1376932 which is for some reason (incorrectly) RESOLVED FIXED.
Comment 59•4 years ago
|
||
Disconnecting a Streamfilter and sending an error only is useless, because then the add-on just bypasses the cache.
Comment 60•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #56)
if we disabled alt-data and an extension were to use a filter on all requests
A add-on can NOT filter all request e.g. addons.mozilla.org. So, this is not the same as flipping the pref.
Comment 61•4 years ago
|
||
The proposed solution doesn't sit well with me. At least in theory, between a public API we expose to extensions (which have stability guarantees we try to maintain) and the bytecode optimization (which sits on top of regular caching as a basic optimization), stability of the API should win every time.
Also, there doesn't seem to be anything fundamentally un-implementable about the whole setup. Unless I'm misunderstanding things, we should be able to have both an optimized path for the common case, and throwing away the bytecode when extension wants to rewrite a script coming from cache.
(Note that I'm not claiming anything about implementing that being simple or easy, just that the two requirements don't strictly cancel each other out, again at least in theory)
In that light, this looks more like a temporary hack than a real solution. Since it looks like extensions that really want to do inspection/rewriting of scripts already work around the current problem via cache busting, they are likely to continue to do so even if we land this "fix", so I'm not sure what this approach really helps with.
That last point is particularly important, since in addition to bytecode caching, extensions are effectively also disabling regular caching for scripts (and possibly other resources, unintentionally). However, if we are able to give extensions specific control of this, perhaps with an additional extraInfoSpec
param like "skipBytecodeCache", then in combination with this proposal (making the FilterResponse throw for scripts without that flag), we might actually be in a better place.
Longer term, I think we should actually aim to have bytecode cache implementation better support the usecase of extensions, but I'll let Valentin speak about feasibility of that.
Comment 62•4 years ago
|
||
(In reply to Tomislav Jovanovic :zombie from comment #61)
In that light, this looks more like a temporary hack than a real solution. Since it looks like extensions that really want to do inspection/rewriting of scripts already work around the current problem via cache busting, they are likely to continue to do so even if we land this "fix", so I'm not sure what this approach really helps with.
Maybe you can add something like this in the details object: fromBytecodeCache: false
Assignee | ||
Comment 63•4 years ago
|
||
Assignee | ||
Comment 64•4 years ago
|
||
Valentin indicated he wasn't concerned that we disable alt-data, though it bothers me a touch, I'm going to go with what he said. So, we do not need any change in the api to get something that will work. At some point, perhaps we'll get some cache work done that will allow this to work when creating the filter in onHeadersReceived.
Assignee | ||
Comment 65•4 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=66a68ad7367413e29ab25af6471992dc51e93e23
Assignee | ||
Comment 66•4 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=451e4a722a22de4672ec7c78504e7c98eacd105d
Comment 67•4 years ago
|
||
Pushed by scaraveo@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3c76ac7b3965 disconnect streamfilter and send error if using cached alt-data in request r=valentin,zombie https://hg.mozilla.org/integration/autoland/rev/77bb11a76b33 add api on channels to prevent using alt-data cache r=valentin https://hg.mozilla.org/integration/autoland/rev/365c4d5fe9b0 disable alt-data if possible when creating a StreamFilter r=valentin,zombie
Comment 68•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3c76ac7b3965
https://hg.mozilla.org/mozilla-central/rev/77bb11a76b33
https://hg.mozilla.org/mozilla-central/rev/365c4d5fe9b0
Assignee | ||
Comment 69•4 years ago
|
||
This should have some additional notes on the mdn docs for filterResponseData. Something along the lines:
Firefox uses an optimized byte cache for script requests that overrides the normal request caching. Data from this alternate cache is not available in a useful form for extensions. If your extension needs to filter scripts, you should create your filter in onBeforeRequest so that the filter is created prior to the attempt to load from cache. In this case, we bypass the alternate cache used for scripts, for the request being handled.
Comment 70•4 years ago
|
||
Thanks for fixing this annoying bug!
Comment 71•4 years ago
|
||
Backed out 3 changesets (Bug 1530408) for causing xpcshell failures in test_ext_webRequest_filterResponseData.js
These xpcshell failures were permafailing on Central:
https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&resultStatus=success%2Ctestfailed%2Cbusted%2Cexception&classifiedState=unclassified&searchStr=linux%2C18.04%2Cx64%2Ctsan%2Copt%2Cxpcshell%2Ctests%2Ctest-linux1804-64-tsan%2Fopt-xpcshell-e10s-1%2Cx%28x1%29
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=296737206&repo=mozilla-central&lineNumber=3006
Backout: https://hg.mozilla.org/integration/autoland/rev/df39286e09e757744f1ab39fd13ec57b5d521520
Comment 72•4 years ago
|
||
Backout merged: https://hg.mozilla.org/mozilla-central/rev/df39286e09e7
Comment 73•4 years ago
|
||
Can this fix be uplifted to Firefox 76?
Assignee | ||
Comment 74•4 years ago
|
||
mDisconnected should only be changed on the main thread.
Assignee | ||
Comment 75•4 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=2a7a89123c3f188178de37a955a55a7a1f458426
Comment 76•4 years ago
|
||
Pushed by scaraveo@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/268925ed4b5c disconnect streamfilter and send error if using cached alt-data in request r=valentin,zombie https://hg.mozilla.org/integration/autoland/rev/8bcb78e10e86 add api on channels to prevent using alt-data cache r=valentin https://hg.mozilla.org/integration/autoland/rev/79632a1a297c disable alt-data if possible when creating a StreamFilter r=valentin,zombie https://hg.mozilla.org/integration/autoland/rev/5bf3acec2165 fix data race setting StreamFilter disconnected r=zombie
Assignee | ||
Updated•4 years ago
|
Comment 77•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/268925ed4b5c
https://hg.mozilla.org/mozilla-central/rev/8bcb78e10e86
https://hg.mozilla.org/mozilla-central/rev/79632a1a297c
https://hg.mozilla.org/mozilla-central/rev/5bf3acec2165
Updated•4 years ago
|
Comment 78•4 years ago
|
||
The patch landed in nightly and beta is affected.
:mixedpuppy, is this bug important enough to require an uplift?
If not please set status_beta
to wontfix
.
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 79•4 years ago
|
||
Considering this issue has been around for a year I'll be more conservative with the fix and let it ride the train.
Comment 80•4 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #69)
This should have some additional notes on the mdn docs for filterResponseData. Something along the lines:
Firefox uses an optimized byte cache for script requests that overrides the normal request caching. Data from this alternate cache is not available in a useful form for extensions. If your extension needs to filter scripts, you should create your filter in onBeforeRequest so that the filter is created prior to the attempt to load from cache. In this case, we bypass the alternate cache used for scripts, for the request being handled.
Can this page also be updated?
It says: Code that is loaded to be executed by a <script> element
But it will only be called, if the script element has a src attribute.
It will not be called for a script element without a src attribute.
Comment 81•4 years ago
|
||
I've added a note to webRequest.filterResponseData() in line with the suggestion in https://bugzilla.mozilla.org/show_bug.cgi?id=1530408#c69. Please let me know if this is OK. I assume no release notes update is necessary.
Updated•4 years ago
|
Description
•