gecko/widget
Kyle Huey 1ffb03e8dc 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
..
android Bug 1191161 - p3 - Surprise update-generated-wrappers changes, r=jchen 2015-08-07 02:09:08 -04:00
cocoa Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
crashtests Bug 1128214 - Avoid a crash when attempting to render windows titlebar specific theme elements with e10s. r=roc 2015-03-10 05:54:59 -05:00
gonk Bug 1192949 - Fix nsScreenGonk::SetMirroringScreen() r=mwu 2015-08-10 16:28:36 -07:00
gtk Bug 863512 - Fixing xul dnd panels for linux. r=enndeakin 2015-08-05 13:19:44 +02:00
gtkxtbin Bug 1126269 - Part 1: Remove nsError.h dependency from C sources in widget/gtk. r=roc 2015-01-30 08:53:46 +09:00
qt Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
reftests
tests Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
uikit Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
windows Bug 1187178 - Use MOZ_WINSDK_MAXVER instead of #ifndef. r=jimm 2015-08-11 14:12:29 +09:00
x11
xremoteclient Bug 1165515 - Part 13-2: Replace usage of PRLogModuleLevel and PR_LOG_*. rs=froydnj 2015-06-03 15:25:57 -07:00
BasicEvents.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
CommandList.h
ContentCache.cpp Bug 1188696 - Hoist nsRefPtr.h into MFBT. r=froydnj 2015-07-29 10:44:59 -07:00
ContentCache.h Bug 1185316 TabParent should flush pending IME notifications after child process handles all sending events r=smaug 2015-07-22 14:51:36 +09:00
ContentEvents.h Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj 2015-03-21 12:28:04 -04:00
ContentHelper.cpp Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
ContentHelper.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
EventClassList.h
EventForwards.h Bug 1162009 - Add TOUCH_CANCEL sending on e10s. r=kats 2015-05-14 08:16:00 -04:00
FontRange.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
GfxDriverInfo.cpp Bug 1180379. Split out GMAX4500 and block those devices from D2D. r=Bas 2015-07-21 18:04:48 -04:00
GfxDriverInfo.h Bug 1180379. Split out GMAX4500 and block those devices from D2D. r=Bas 2015-07-21 18:04:48 -04:00
GfxInfoBase.cpp Bug 1191404 - Update the comments to avoid confusion about what happens with blocklisting when the OS is unknown. No code change. r=milan 2015-08-05 10:39:00 +02:00
GfxInfoBase.h Add compositor, layers, and rendering info to nsIGfxInfo. (bug 1179051 part 5, r=mattwoodrow) 2015-07-19 14:50:35 -07:00
GfxInfoCollector.cpp Bug 1125356 - Use JS_NewPlainObject in the browser. r=bz 2015-01-24 16:38:08 +01:00
GfxInfoCollector.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
GfxInfoWebGL.cpp
GfxInfoWebGL.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
GfxInfoX11.cpp Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
GfxInfoX11.h bug 1175005: performance regression. backout_f081c464c1e2 2015-07-09 11:48:06 +01:00
IMEData.h Bug 1192156 Separate IME specific structs, classes and enums from nsIWidget.h to IMEData.h r=roc 2015-08-09 00:47:19 +09:00
InputData.cpp Bug 1120683 - Properly handle unapplying 3D projective transforms throughout APZ code. r=botond 2015-07-03 15:06:26 -04:00
InputData.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
LookAndFeel.h Backed out changeset 7edc58c272f1 (bug 1075089) for causing OS X 10.6 marionette failures in test_single_finger_desktop.py testSingleFingerMouse.test_double_tap on a CLOSED TREE 2015-07-31 14:49:40 +02:00
MiscEvents.h Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj 2015-03-21 12:28:04 -04:00
MouseEvents.h Backed out changeset 427cfffcb5b7 (bug 1000870) 2015-08-03 16:37:18 +02:00
moz.build Bug 1192156 Separate IME specific structs, classes and enums from nsIWidget.h to IMEData.h r=roc 2015-08-09 00:47:19 +09:00
NativeKeyToDOMCodeName.h Bug 1020139 part.3 Map special keys on Sun keyboard on Android and Gonk r=cpeterson 2015-02-04 11:01:19 +09:00
NativeKeyToDOMKeyName.h Bug 1039866 - Rip out a bunch of metro-only code. r=jimm,gavin,rstrong 2015-04-23 15:10:30 -04:00
nsAppShellSingleton.h Bug 1039866 - Rip out a bunch of metro-only code. r=jimm,gavin,rstrong 2015-04-23 15:10:30 -04:00
nsBaseAppShell.cpp Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
nsBaseAppShell.h Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
nsBaseClipboard.cpp
nsBaseClipboard.h
nsBaseDragService.cpp Bug 941858 - Do not scale down elements passed to setDragImage. r=roc 2015-07-11 10:15:19 -06:00
nsBaseDragService.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
nsBaseFilePicker.cpp Bug 1164310, part 4 - Implement the new HTMLInputElement API including the new Promise returning GetFilesAndDirectories. r=baku 2015-07-10 18:55:52 +01:00
nsBaseFilePicker.h Bug 1163388 - patch 2 - get rid of nsIDOMFile, r=ehsan 2015-05-18 14:52:26 +01:00
nsBaseScreen.cpp Back out Bug 1127201 (part 2) for various problems. 2015-02-06 15:04:32 -08:00
nsBaseScreen.h Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj 2015-03-21 12:28:04 -04:00
nsBaseWidget.cpp Bug 1191213 nsBaseWidget::NotifyWindowMoved() shouldn't notify IME when native IME handler doesn't have focus r=m_kato 2015-08-06 15:57:58 +09:00
nsBaseWidget.h Bug 1191213 nsBaseWidget::NotifyWindowMoved() shouldn't notify IME when native IME handler doesn't have focus r=m_kato 2015-08-06 15:57:58 +09:00
nsClipboardHelper.cpp Bug 1166840 - Remove document argument from nsIClipboardHelper.copyString{,ToClipboard}. r=ehsan 2015-05-21 21:50:09 +01:00
nsClipboardHelper.h
nsClipboardProxy.cpp Bug 1071562, e10s, support non-text types in clipboard (html, images, etc), r=smaug 2015-04-16 15:38:12 -04:00
nsClipboardProxy.h Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj 2015-03-21 12:28:04 -04:00
nsColorPickerProxy.cpp Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
nsColorPickerProxy.h Bug 1148527 - Indentation fix after bug 1145631, r=ehsan 2015-03-27 18:52:19 +00:00
nsContentProcessWidgetFactory.cpp Bug 1154182 - enable native keybindings for graphene. r=billm 2015-04-15 21:17:00 +02:00
nsDragServiceProxy.cpp Bug 1071562, e10s, support non-text types in clipboard (html, images, etc), r=smaug 2015-04-16 15:38:12 -04:00
nsDragServiceProxy.h Bug 936092, initial DnD support for e10s, r=enndeakin,karlt 2015-04-08 21:48:11 +03:00
nsFilePickerProxy.cpp Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
nsFilePickerProxy.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
nsGUIEventIPC.h Bug 1184449 part.1 IMENotifiation::SelectionChangeData should store selected string r=smaug 2015-07-22 12:40:32 +09:00
nsHTMLFormatConverter.cpp
nsHTMLFormatConverter.h
nsIApplicationChooser.idl Bug 1129873 - [GTK3] Implement wrapper to GtkAppChooserDialog to allow using native application chooser. r=karlt 2015-06-08 04:41:00 -04:00
nsIAppShell.idl Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
nsIBaseWindow.idl
nsIBidiKeyboard.idl Bug 1155214 - Mark nsIBidiKeyboard as builtinclass; r=mrbkap 2015-04-16 16:14:35 -04:00
nsIClipboard.idl
nsIClipboardDragDropHookList.idl
nsIClipboardDragDropHooks.idl
nsIClipboardHelper.idl Bug 1166840 - Remove document argument from nsIClipboardHelper.copyString{,ToClipboard}. r=ehsan 2015-05-21 21:50:09 +01:00
nsIClipboardOwner.idl
nsIColorPicker.idl
nsIDeviceContextSpec.h
nsIDisplayInfo.idl Bug 1138287 - Part 2: Support multi-screen on Gonk platform. r=mwu, r=sotaro, r=jgilbert, r=mattwoodrow 2015-06-05 11:29:30 +08:00
nsIdleService.cpp Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
nsIdleService.h
nsIDragService.idl Bug 936092, initial DnD support for e10s, r=enndeakin,karlt 2015-04-08 21:48:11 +03:00
nsIDragSession.idl Bug 936092, initial DnD support for e10s, r=enndeakin,karlt 2015-04-08 21:48:11 +03:00
nsIFilePicker.idl Bug 1163388 - patch 2 - get rid of nsIDOMFile, r=ehsan 2015-05-18 14:52:26 +01:00
nsIFormatConverter.idl
nsIGfxInfo2.idl
nsIGfxInfo.idl Bug 1178069 - Check devices capability before enable use of vp8 hardware acceleration using android.media.MediaCodecList and android.media.MediaCodecInfo r=jrmuizel 2015-07-24 12:45:55 -07:00
nsIGfxInfoDebug.idl
nsIIdleService.idl
nsIIdleServiceInternal.idl
nsIIMEPicker.idl
nsIJumpListBuilder.idl
nsIJumpListItem.idl
nsIMacDockSupport.idl
nsIMacWebAppUtils.idl
nsINativeMenuService.h
nsIPluginWidget.h Bug 1155621 - Make nsIntRect and nsIntPoint typedefs of mozilla::gfx::IntRect and mozilla::gfx::IntPoint. r=Bas 2015-04-21 17:04:57 +02:00
nsIPrintDialogService.h
nsIPrintOptions.idl Bug 1082579 followup: Forward-declare 'PrintData' as 'class' instead of 'struct', since ipdl apparently converts 'struct' to 'class'. rs=mconley 2015-03-09 10:52:18 -07:00
nsIPrintSession.idl
nsIPrintSettings.idl bug 147419 remove ununsed plexName colorspace resolutionName and downloadFonts r=roc 2015-06-11 09:34:27 +12:00
nsIPrintSettingsService.idl
nsIPrintSettingsWin.idl
nsIRollupListener.h Bug 1155621 - Make nsIntRect and nsIntPoint typedefs of mozilla::gfx::IntRect and mozilla::gfx::IntPoint. r=Bas 2015-04-21 17:04:57 +02:00
nsIScreen.idl
nsIScreenManager.idl
nsISound.idl
nsIStandaloneNativeMenu.idl
nsISystemStatusBar.idl
nsITaskbarOverlayIconController.idl
nsITaskbarPreview.idl
nsITaskbarPreviewButton.idl
nsITaskbarPreviewController.idl
nsITaskbarProgress.idl
nsITaskbarTabPreview.idl
nsITaskbarWindowPreview.idl
nsITransferable.idl
nsIWidget.h Bug 1192156 Separate IME specific structs, classes and enums from nsIWidget.h to IMEData.h r=roc 2015-08-09 00:47:19 +09:00
nsIWidgetListener.cpp Bug 1161802 part 1 - Add FullscreenChanged callback in WidgetListener. r=roc 2015-06-10 23:13:12 +12:00
nsIWidgetListener.h Bug 1161802 part 1 - Add FullscreenChanged callback in WidgetListener. r=roc 2015-06-10 23:13:12 +12:00
nsIWindowsUIUtils.idl Bug 1170522 - expose whether or not we're in tablet mode to xul/js/css, r=jimm,ted 2015-06-16 19:51:29 +01:00
nsIWinTaskbar.idl
nsNativeTheme.cpp Bug 1134280 - Get rid of Tag() - patch 2.13 - Fix all the occurrences, m=smaug, r=surkov 2015-03-03 11:09:00 +00:00
nsNativeTheme.h Bug 1066531 - Delay tab switching until content is ready in e10s mode r=mconley,mstange 2015-03-16 14:30:41 -04:00
nsPrimitiveHelpers.cpp Bug 1170794 - Improve the length check of the input in nsUnicode*::GetMaxLength, r=dveditz 2015-06-17 12:21:39 +01:00
nsPrimitiveHelpers.h Bug 1134920 drive-by comment fix. DONTBUILD 2015-05-02 03:01:06 +12:00
nsPrintOptionsImpl.cpp bug 147419 remove ununsed plexName colorspace resolutionName and downloadFonts r=roc 2015-06-11 09:34:27 +12:00
nsPrintOptionsImpl.h
nsPrintSession.cpp
nsPrintSession.h
nsPrintSettingsImpl.cpp Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan 2015-08-04 16:17:36 -07:00
nsPrintSettingsImpl.h bug 147419 remove ununsed plexName colorspace resolutionName and downloadFonts r=roc 2015-06-11 09:34:27 +12:00
nsScreenManagerProxy.cpp Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
nsScreenManagerProxy.h Bug 1148527 - Indentation fix after bug 1145631, r=ehsan 2015-03-27 18:52:19 +00:00
nsShmImage.cpp Bug 1167786. Restrict bounds of drawn region to the nsShmImage bounds to avoid X errors. r=karlt 2015-07-14 00:03:44 +12:00
nsShmImage.h Bug 1168843 - use thread-safe refcounting for shared memory surfaces to avoid shutdown crashes. r=jmuizelaar 2015-05-27 11:20:26 -04:00
nsTransferable.cpp Bug 905127 - Part 1 - Make some functions from nsNetUtil not inline. r=jduell 2015-07-07 04:17:00 +02:00
nsTransferable.h Bug 1123480 - Component: widget nsTransferable private browsing correction. r=jdm 2015-02-18 06:52:00 -05:00
nsWidgetInitData.h Enable APZ for all Desktop windows if E10s is enabled. (bug 1163115, r=kats) 2015-05-12 01:26:01 -04:00
nsWidgetsCID.h Bug 1170522 - expose whether or not we're in tablet mode to xul/js/css, r=jimm,ted 2015-06-16 19:51:29 +01:00
nsXPLookAndFeel.cpp Backed out changeset 7edc58c272f1 (bug 1075089) for causing OS X 10.6 marionette failures in test_single_finger_desktop.py testSingleFingerMouse.test_double_tap on a CLOSED TREE 2015-07-31 14:49:40 +02:00
nsXPLookAndFeel.h Backed out changeset 5f9c7cd773a5 (bug 1096093) for bustage on a CLOSED TREE 2015-04-23 17:18:52 +02:00
PluginWidgetProxy.cpp Backed out changeset f612649fdbaf (bug 1174461) for causing bug bug 1182919. a=topcrash 2015-07-15 12:44:01 -04:00
PluginWidgetProxy.h Backed out changeset f612649fdbaf (bug 1174461) for causing bug bug 1182919. a=topcrash 2015-07-15 12:44:01 -04:00
PuppetBidiKeyboard.cpp Bug 966395 - Correctly propagate the input language's direction on OSX. r=masayuki/mrbkap 2015-04-10 15:18:05 -07:00
PuppetBidiKeyboard.h Bug 966395 - Correctly propagate the input language's direction on OSX. r=masayuki/mrbkap 2015-04-10 15:18:05 -07:00
PuppetWidget.cpp Bug 1183828 - Remove 'nsWindow::GetNativeData not implemented for this type' warning. r=roc 2015-07-25 10:43:27 -07:00
PuppetWidget.h Bug 1157941 - If the current PresShell is suppressed, paint the old one if it is available r=tn,Enn 2015-07-21 21:09:02 -04:00
ScreenProxy.cpp Bug 1179909: Refactor stable state handling. r=smaug 2015-08-11 06:10:46 -07:00
ScreenProxy.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
SharedWidgetUtils.cpp Bug 1119609 part.3 Implement converting methods from key/code value to key/code name index r=smaug 2015-02-19 15:50:19 +09:00
TextEventDispatcher.cpp Bug 1119133 Implement TextEventDispatcher::EndInputTransaction() for ensuring TextEventDispatcher forgets the link with TextInputProcessor r=smaug 2015-06-11 12:53:42 +09:00
TextEventDispatcher.h Bug 1119133 Implement TextEventDispatcher::EndInputTransaction() for ensuring TextEventDispatcher forgets the link with TextInputProcessor r=smaug 2015-06-11 12:53:42 +09:00
TextEventDispatcherListener.h Bug 917322 part.15 Create TextEventDispatcherListener abstract class for listening notifications to IME r=smaug, sr=smaug 2015-01-28 15:27:32 +09:00
TextEvents.h Bug 1179695 - Remove mWasAsync from WidgetQueryContentEvent. r=masayuki,nchen 2015-07-09 15:09:56 +09:00
TextRange.h Bug 1175382 TextRangeArray::TargetClauseOffset() and TextRangeArray::TargetClauseLength() shouldn't be public and same name methods of WidgetCompositionEvent should be used r=m_kato 2015-06-18 13:43:18 +09:00
TouchEvents.h Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj 2015-03-21 12:28:04 -04:00
VsyncDispatcher.cpp Bug 1134385. Delete main thread assertion in CompositorVsyncDispatcher. r=kats 2015-04-20 17:28:25 -07:00
VsyncDispatcher.h Bug 1188696 - Hoist nsRefPtr.h into MFBT. r=froydnj 2015-07-29 10:44:59 -07:00
WidgetEventImpl.cpp Bug 1158425 - Rename _SYNTH event names. r=smaug 2015-05-01 22:06:00 -04:00
WidgetMessageUtils.h Backed out changeset 5f9c7cd773a5 (bug 1096093) for bustage on a CLOSED TREE 2015-04-23 17:18:52 +02:00
WidgetTraceEvent.h Bug 1182996 - Fix and add missing namespace comments. rs=ehsan 2015-07-13 08:25:42 -07:00
WidgetUtils.cpp Bug 1166436 part.1 Create mozilla::ContentCache and TabParent should store the text to it r=m_kato 2015-06-05 18:28:18 +09:00
WidgetUtils.h Bug 1137555 - Add implementation of PuppetWidget::GetMaxTouchPoints(). r=smaug, r=jimm 2015-05-08 03:29:00 +02:00