OnStopRequest doesn't seem to be always called after Cancel
Categories
(Core :: Networking: HTTP, defect, P2)
Tracking
()
People
(Reporter: julienw, Assigned: kershaw)
References
Details
(Whiteboard: [necko-triaged])
Attachments
(2 files)
Here is my STR:
- Open cnn.com.
- Press "escape" quickly while it's loading.
According to the profiler output and some local tests I made, we enter AsyncOpen with a NS_OK result, but never enter OnStopRequest.
| Reporter | ||
Comment 1•5 years ago
|
||
I also made this pernosco session out of this test file.
| Reporter | ||
Comment 2•5 years ago
|
||
According to the profiler, here are some URLs that don't seem to go through onStopRequest in the previous log:
https://edition.cnn.com/optimizelyjs/128727546.js
https://lightning.cnn.com/launch/7be62238e4c3/97fa00444124/launch-2878c87af5e3.min.js
https://amplify.outbrain.com/cp/obtp.js
https://cdn.cnn.com/cnn/.e/img/3.0/global/misc/apple-touch-icon.png
https://edition.cnn.com/favicon.ie9.ico
https://a.postrelease.com/serve/load.js?async=true
https://cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json
https://edition.cnn.com/optimizelyjs/128727546.js
https://lightning.cnn.com/launch/7be62238e4c3/97fa00444124/launch-2878c87af5e3.min.js
https://mms.cnn.com/get_site_data?account_id=328&href=https%3A%2F%2Fedition.cnn.com%2F&requestUUID=948aa898-9c59-4ad0-a934-62e03aa2c7d4-1628606782487
https://z.cdp-dev.cnn.com/zfm/zfh.js
https://a.postrelease.com/serve/load.js?async=true
https://static.chartbeat.com/js/chartbeat_mab.js
https://tag.bounceexchange.com/340/i.js
https://amplify.outbrain.com/cp/obtp.js
https://static.ads-twitter.com/uwt.js
https://get.s-onetag.com/c15ddde9-ec7d-4a49-b8ca-7a21bc4b943b/tag.min.js
https://live.rezync.com/sync?c=16b6410431b6374e780104abb0443ca8&p=34747f0775f02a6784bb965de6833e73&k=cnn-pixel-8786&zmpID=cnn&custom1=%22section_intl_homepage1%22&custom2=%22section%22&custom3=%22intl_homepage%22&cache_buster=1628606782513
https://secure.quantserve.com/quant.js
https://w.usabilla.com/c3244e3d16ba.js?lv=1
https://cdn.cnn.com/cnnnext/dam/assets/210805175930-01-cambo-uk-oil-field-protest-restricted-large-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210809205808-virginia-giuffre-prince-andrew-split-medium-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210803231700-02-wuhan-citywide-covid-19-testing-medium-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210810153023-01-messi-paris-0810-medium-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210810104201-01-christina-applegate-file-2019-medium-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210701045256-lead-01-alphonso-davies-large-tease.jpg
https://cdn.cnn.com/cnnnext/dam/assets/200224095740-warren-buffett-0918-file-small-11.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210808205958-crocodile-attack-airlift-0806-small-11.jpg
https://cdn.cnn.com/cnnnext/dam/assets/210722221701-01-richard-hutchins-formerly-homeless-artist-small-11.jpg
I believe some of them were blocked by ublock or Firefox' tracking protection (which, I think, go through CancelInternal as well?), but at least the images at the end were probably canceled by my pressing of escape.
| Assignee | ||
Comment 3•5 years ago
|
||
I'll investigate this.
Another question to Julien: I assume that OnStopRequest is not called in content process, right? If so, could you also upload the http log from content processes? Thanks.
| Reporter | ||
Comment 4•5 years ago
|
||
The content processes look right actually (according to the profiler still) !
I'm not sure why, the logs I got weren't really useful for the child processes, they were very short. I used about:networking#logging to set up the logging, maybe that's why?
| Reporter | ||
Comment 5•5 years ago
|
||
I forgot to mention here: I see the same problems in service workers (so with InterceptedHttpChannel.cpp). This can be tested with profiler.firefox.com itself or lemonde.fr.
| Assignee | ||
Comment 6•5 years ago
|
||
According to the log, here is what happened when a channel is cancelled:
2021-08-10 14:46:21.164629 UTC - [Parent 484480: Main Thread]: V/nsHttp nsHttpChannel::Cancel [this=7fe85de04000 status=80004004]
2021-08-10 14:46:21.164631 UTC - [Parent 484480: Main Thread]: V/nsHttp 7fe85de04000 called from script: resource://gre/modules/WebRequest.jsm:996:18
2021-08-10 14:46:21.164661 UTC - [Parent 484480: Main Thread]: V/nsHttp nsHttpChannel::ResumeInternal [this=7fe85de04000]
2021-08-10 14:46:21.174773 UTC - [Parent 484480: Main Thread]: D/nsHttp HttpAsyncAborter::AsyncAbort [this=7fe85de04000 status=80004004]
2021-08-10 14:46:21.177871 UTC - [Parent 484480: Main Thread]: V/nsHttp HttpBaseChannel::DoNotifyListener this=7fe85de04000
You can see that HttpBaseChannel::DoNotifyListener is called. This is how we make sure that mListener->OnStopRequest is called. Note that what nsHttpChannel code guarantees is OnStartRequest and OnStopRequest of its mListenr MUST be always called. It's possible that nsHttpChannel::OnStartRequest and nsHttpChannel::OnStopRequest are not called when a channel is cancelled. I think that's the reason that profiler shows that OnStopRequest is not called.
The same logic also applies to InterceptedHttpChannel. It's possible that InterceptedHttpChannel::OnStopRequest won't be called, when AsyncAbort is called here.
So, I think the question is: do we want to also add network markers in HttpBaseChannel::DoNotifyListener?
| Reporter | ||
Comment 7•5 years ago
|
||
No, I don't think we want to do that.
But it's still not clear to me why OnStopRequest isn't called from DoNotifyListener in this case, do you know?
| Assignee | ||
Comment 8•5 years ago
•
|
||
(In reply to Julien Wajsberg [:julienw] from comment #7)
No, I don't think we want to do that.
But it's still not clear to me why
OnStopRequestisn't called fromDoNotifyListenerin this case, do you know?
Which OnStopRequest? Do you mean nsHttpChannel::OnStopRequest?
Note that DoNotifyListener only calls mListener's OnStartRequest and OnStopRequest.
| Reporter | ||
Comment 9•5 years ago
|
||
So does that mean that mListener is removed after the cancelation ? Is that normal ?
My understanding was that nsHttpChannel::OnStopRequest should be called in all situations, if AsyncOpen succeeded before that. Is this incorrect?
| Assignee | ||
Comment 10•5 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #9)
So does that mean that
mListeneris removed after the cancelation ? Is that normal ?
Not sure if I understand your question. mListener will be released here to make sure that both the channel and mListener can be released.
My understanding was that
nsHttpChannel::OnStopRequestshould be called in all situations, ifAsyncOpensucceeded before that. Is this incorrect?
No, it's not correct. As I said in comment #6, nsHttpChannel::OnStopRequest will not be always called. We only make sure that mListener's OnStartRequest and OnStopRequest will be called in all cases.
| Reporter | ||
Comment 11•5 years ago
|
||
(In reply to Kershaw Chang [:kershaw] from comment #10)
(In reply to Julien Wajsberg [:julienw] from comment #9)
So does that mean that
mListeneris removed after the cancelation ? Is that normal ?Not sure if I understand your question.
mListenerwill be released here to make sure that both the channel andmListenercan be released.My understanding was that
nsHttpChannel::OnStopRequestshould be called in all situations, ifAsyncOpensucceeded before that. Is this incorrect?No, it's not correct. As I said in comment #6,
nsHttpChannel::OnStopRequestwill not be always called. We only make sure thatmListener'sOnStartRequestandOnStopRequestwill be called in all cases.
OK, that's what Valentin said in my patch in https://phabricator.services.mozilla.com/D122111, but I guess there's a misunderstanding.
May I ask what object is usually in mListener?
| Assignee | ||
Comment 12•5 years ago
|
||
OK, that's what Valentin said in my patch in https://phabricator.services.mozilla.com/D122111, but I guess there's a misunderstanding.
I think the OnStopRequest that Valentin meant belongs to mListener, not nsHttpChannel::OnStopRequest.
May I ask what object is usually in
mListener?
The mListener here is usually the same as the listener that passes to AsyncOpen function.
| Assignee | ||
Comment 13•4 years ago
|
||
Close as INVALID, since this is really not an issue.
Description
•