gecko-dev/netwerk
Kyle Huey 76e3009ab8 Bug 1179909: Refactor stable state handling. r=smaug
This is motivated by three separate but related problems:

1. Our concept of recursion depth is broken for things that run from AfterProcessNextEvent observers (e.g. Promises). We decrement the recursionDepth counter before firing observers, so a Promise callback running at the lowest event loop depth has a recursion depth of 0 (whereas a regular nsIRunnable would be 1). This is a problem because it's impossible to distinguish a Promise running after a sync XHR's onreadystatechange handler from a top-level event (since the former runs with depth 2 - 1 = 1, and the latter runs with just 1).

2. The nsIThreadObserver mechanism that is used by a lot of code to run "after" the current event is a poor fit for anything that runs script. First, the order the observers fire in is the order they were added, not anything fixed by spec. Additionally, running script can cause the event loop to spin, which is a big source of pain here (bholley has some nasty bug caused by this).

3. We run Promises from different points in the code for workers and main thread. The latter runs from XPConnect's nsIThreadObserver callbacks, while the former runs from a hardcoded call to run Promises in the worker event loop. What workers do is particularly problematic because it means we can't get the right recursion depth no matter what we do to nsThread.

The solve this, this patch does the following:

1. Consolidate some handling of microtasks and all handling of stable state from appshell and WorkerPrivate into CycleCollectedJSRuntime.
2. Make the recursionDepth counter only available to CycleCollectedJSRuntime (and its consumers) and remove it from the nsIThreadInternal and nsIThreadObserver APIs.
3. Adjust the recursionDepth counter so that microtasks run with the recursionDepth of the task they are associated with.
4. Introduce the concept of metastable state to replace appshell's RunBeforeNextEvent. Metastable state is reached after every microtask or task is completed. This provides the semantics that bent and I want for IndexedDB, where transactions autocommit at the end of a microtask and do not "spill" from one microtask into a subsequent microtask. This differs from appshell's RunBeforeNextEvent in two ways:
a) It fires between microtasks, which was the motivation for starting this.
b) It no longer ensures that we're at the same event loop depth in the native event queue. bent decided we don't care about this.
5. Reorder stable state to happen after microtasks such as Promises, per HTML. Right now we call the regular thread observers, including appshell, before the main thread observer (XPConnect), so stable state tasks happen before microtasks.
2015-08-11 06:10:46 -07:00
..
base Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
build Bug 1127618 - make push caches work in e10s. r=mcmanus r=froydnj IGNORE IDL 2015-07-31 13:50:08 -07:00
cache Bug 1191144 - Remove CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_NSCACHESERVICE_LEAVEPRIVATEBROWSING; r=michal 2015-08-05 11:42:21 -04:00
cache2 Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
cookie Backout bff74cecc67c, ffe0edb2aae7, b60b7c267cef, 6da154b43265, bcf6fd3ab9bb (bug 1182961 parts 1--5) for possible intermittent failures and performance problems. 2015-08-06 16:30:47 -07:00
dns Bug 1190502 - RESOLVE_DISABLE_IPV4 returns A records r=mcmanus 2015-08-10 11:22:02 +02:00
ipc Bug 1127618 - make push caches work in e10s. r=mcmanus r=froydnj IGNORE IDL 2015-07-31 13:50:08 -07:00
locales Bug 1079338 - Log resources blocked by tracking protection. r=mcmanus,mmc,dcamp 2014-10-10 12:19:14 -07:00
mime Bug 1170837 - Make nsMultiMixedConv not return an error when served only a package's metadata from the cache r=honzab 2015-07-23 17:38:33 +02:00
protocol Bug 1179255 - (fatal) Assertion failure: aRequest == mCancelable, at netwerk/protocol/websocket/WebSocketChannel.cpp:2766, r=mcmanus 2015-08-11 14:50:08 +02:00
sctp Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
socket Bug 1188205 - Fix more constructors in netwerk; r=mcmanus 2015-07-28 08:53:24 -04:00
srtp Bug 1123527 - Fix syntax error when ERR_REPORTING_SYSLOG is defined. r=jesup. 2015-01-21 22:21:31 -08:00
standalone Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
streamconv Bug 1170837 - Make nsMultiMixedConv not return an error when served only a package's metadata from the cache r=honzab 2015-07-23 17:38:33 +02:00
system Bug 1191258 - check for IFF_RUNNING to detect online interfaces. r=mcmanus 2015-08-05 03:22:00 +02:00
test Bug 1190502 - RESOLVE_DISABLE_IPV4 returns A records r=mcmanus 2015-08-10 11:22:02 +02:00
wifi Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
Makefile.in
moz.build Bug 1097804 - Part 1 - Create a library containing nsISocketTransportService and nsIDNS that can be used to support standalone WebRTC. r=mcmanus 2015-04-03 15:54:00 +02:00
necko-config.h.in