Back out bug 606574 for leaking a Mutex and a CondVar in crashtests

This commit is contained in:
Ehsan Akhgari 2011-04-13 14:08:43 -04:00
parent 4f75a1c3e1
commit 2bee451447
19 changed files with 83 additions and 822 deletions

View File

@ -716,8 +716,6 @@ ANDROID_PACKAGE_NAME = @ANDROID_PACKAGE_NAME@
JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@ JS_SHARED_LIBRARY = @JS_SHARED_LIBRARY@
MOZ_INSTRUMENT_EVENT_LOOP = @MOZ_INSTRUMENT_EVENT_LOOP@
# We only want to do the pymake sanity on Windows, other os's can cope # We only want to do the pymake sanity on Windows, other os's can cope
ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH))) ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH)))
# Ensure invariants between GNU Make and pymake # Ensure invariants between GNU Make and pymake

View File

@ -5203,7 +5203,6 @@ cairo-windows)
;; ;;
esac esac
MOZ_PDF_PRINTING=1 MOZ_PDF_PRINTING=1
MOZ_INSTRUMENT_EVENT_LOOP=1
;; ;;
cairo-gtk2|cairo-gtk2-x11) cairo-gtk2|cairo-gtk2-x11)
@ -5221,7 +5220,6 @@ cairo-gtk2|cairo-gtk2-x11)
TK_LIBS='$(MOZ_GTK2_LIBS)' TK_LIBS='$(MOZ_GTK2_LIBS)'
AC_DEFINE(MOZ_WIDGET_GTK2) AC_DEFINE(MOZ_WIDGET_GTK2)
MOZ_PDF_PRINTING=1 MOZ_PDF_PRINTING=1
MOZ_INSTRUMENT_EVENT_LOOP=1
;; ;;
cairo-gtk2-dfb) cairo-gtk2-dfb)
@ -5281,7 +5279,6 @@ cairo-cocoa)
LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL' LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
MOZ_FS_LAYOUT=bundle MOZ_FS_LAYOUT=bundle
MOZ_WEBGL=1 MOZ_WEBGL=1
MOZ_INSTRUMENT_EVENT_LOOP=1
;; ;;
cairo-android) cairo-android)
@ -5305,10 +5302,6 @@ if test "$MOZ_ENABLE_XREMOTE"; then
AC_DEFINE(MOZ_ENABLE_XREMOTE) AC_DEFINE(MOZ_ENABLE_XREMOTE)
fi fi
if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
fi
if test "$COMPILE_ENVIRONMENT"; then if test "$COMPILE_ENVIRONMENT"; then
if test "$MOZ_ENABLE_GTK2"; then if test "$MOZ_ENABLE_GTK2"; then
if test "$MOZ_X11"; then if test "$MOZ_X11"; then
@ -9192,7 +9185,6 @@ AC_SUBST(VPX_AS_CONVERSION)
AC_SUBST(VPX_ASM_SUFFIX) AC_SUBST(VPX_ASM_SUFFIX)
AC_SUBST(VPX_X86_ASM) AC_SUBST(VPX_X86_ASM)
AC_SUBST(VPX_ARM_ASM) AC_SUBST(VPX_ARM_ASM)
AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
AC_SUBST(LIBJPEG_TURBO_AS) AC_SUBST(LIBJPEG_TURBO_AS)
AC_SUBST(LIBJPEG_TURBO_ASFLAGS) AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
AC_SUBST(LIBJPEG_TURBO_X86_ASM) AC_SUBST(LIBJPEG_TURBO_X86_ASM)

View File

@ -1,182 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Event loop instrumentation. This code attempts to measure the
* latency of the UI-thread event loop by firing native events at it from
* a background thread, and measuring how long it takes for them
* to be serviced. The measurement interval (kMeasureInterval, below)
* is also used as the upper bound of acceptable response time.
* When an event takes longer than that interval to be serviced,
* a sample will be written to the log.
*
* Usage:
*
* Set MOZ_INSTRUMENT_EVENT_LOOP=1 in the environment to enable
* this instrumentation. Currently only the UI process is instrumented.
*
* Set MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT in the environment to a
* file path to contain the log output, the default is to log to stdout.
*
* All logged output lines start with MOZ_EVENT_TRACE. All timestamps
* output are milliseconds since the epoch (PRTime / 1000).
*
* On startup, a line of the form:
* MOZ_EVENT_TRACE start <timestamp>
* will be output.
*
* On shutdown, a line of the form:
* MOZ_EVENT_TRACE stop <timestamp>
* will be output.
*
* When an event servicing time exceeds the threshold, a line of the form:
* MOZ_EVENT_TRACE sample <timestamp> <duration>
* will be output, where <duration> is the number of milliseconds that
* it took for the event to be serviced.
*/
#include "EventTracer.h"
#include <stdio.h>
#include "mozilla/TimeStamp.h"
#include "mozilla/WidgetTraceEvent.h"
#include <prenv.h>
#include <prinrval.h>
#include <prthread.h>
#include <prtime.h>
using mozilla::TimeDuration;
using mozilla::TimeStamp;
using mozilla::FireAndWaitForTracerEvent;
namespace {
PRThread* sTracerThread = NULL;
bool sExit = false;
/*
* The tracer thread fires events at the native event loop roughly
* every kMeasureInterval. It will sleep to attempt not to send them
* more quickly, but if the response time is longer than kMeasureInterval
* it will not send another event until the previous response is received.
*
* The output defaults to stdout, but can be redirected to a file by
* settting the environment variable MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT
* to the name of a file to use.
*/
void TracerThread(void *arg)
{
// This should be set to the maximum latency we'd like to allow
// for responsiveness.
const PRIntervalTime kMeasureInterval = PR_MillisecondsToInterval(50);
FILE* log = NULL;
char* envfile = PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT");
if (envfile) {
log = fopen(envfile, "w");
}
if (log == NULL)
log = stdout;
fprintf(log, "MOZ_EVENT_TRACE start %llu\n", PR_Now() / PR_USEC_PER_MSEC);
while (!sExit) {
TimeStamp start(TimeStamp::Now());
PRIntervalTime next_sleep = kMeasureInterval;
//TODO: only wait up to a maximum of kMeasureInterval, return
// early if that threshold is exceeded and dump a stack trace
// or do something else useful.
if (FireAndWaitForTracerEvent()) {
TimeDuration duration = TimeStamp::Now() - start;
// Only report samples that exceed our measurement interval.
if (duration.ToMilliseconds() > kMeasureInterval) {
fprintf(log, "MOZ_EVENT_TRACE sample %llu %d\n",
PR_Now() / PR_USEC_PER_MSEC,
int(duration.ToSecondsSigDigits() * 1000));
}
if (next_sleep > duration.ToMilliseconds()) {
next_sleep -= int(duration.ToMilliseconds());
}
else {
// Don't sleep at all if this event took longer than the measure
// interval to deliver.
next_sleep = 0;
}
}
if (next_sleep != 0 && !sExit) {
PR_Sleep(next_sleep);
}
}
fprintf(log, "MOZ_EVENT_TRACE stop %llu\n", PR_Now() / PR_USEC_PER_MSEC);
if (log != stdout)
fclose(log);
}
} // namespace
namespace mozilla {
bool InitEventTracing()
{
// Create a thread that will fire events back at the
// main thread to measure responsiveness.
NS_ABORT_IF_FALSE(!sTracerThread, "Event tracing already initialized!");
sTracerThread = PR_CreateThread(PR_USER_THREAD,
TracerThread,
NULL,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD,
0);
return sTracerThread != NULL;
}
void ShutdownEventTracing()
{
sExit = true;
if (sTracerThread)
PR_JoinThread(sTracerThread);
sTracerThread = NULL;
}
} // namespace mozilla

View File

@ -1,54 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef XRE_EVENTTRACER_H_
#define XRE_EVENTTRACER_H_
namespace mozilla {
// Create a thread that will fire events back at the
// main thread to measure responsiveness. Return true
// if the thread was created successfully.
bool InitEventTracing();
// Signal the background thread to stop, and join it.
// Must be called from the same thread that called InitEventTracing.
void ShutdownEventTracing();
} // namespace mozilla
#endif /* XRE_EVENTTRACER_H_ */

View File

@ -88,8 +88,6 @@ private:
static PRBool sProcessedGetURLEvent = PR_FALSE; static PRBool sProcessedGetURLEvent = PR_FALSE;
@class GeckoNSApplication;
// Methods that can be called from non-Objective-C code. // Methods that can be called from non-Objective-C code.
// This is needed, on relaunch, to force the OS to use the "Cocoa Dock API" // This is needed, on relaunch, to force the OS to use the "Cocoa Dock API"
@ -99,7 +97,7 @@ EnsureUseCocoaDockAPI()
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK; NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
[GeckoNSApplication sharedApplication]; [NSApplication sharedApplication];
NS_OBJC_END_TRY_ABORT_BLOCK; NS_OBJC_END_TRY_ABORT_BLOCK;
} }
@ -114,7 +112,7 @@ SetupMacApplicationDelegate()
AutoAutoreleasePool pool; AutoAutoreleasePool pool;
// Ensure that ProcessPendingGetURLAppleEvents() doesn't regress bug 377166. // Ensure that ProcessPendingGetURLAppleEvents() doesn't regress bug 377166.
[GeckoNSApplication sharedApplication]; [NSApplication sharedApplication];
// This call makes it so that application:openFile: doesn't get bogus calls // This call makes it so that application:openFile: doesn't get bogus calls
// from Cocoa doing its own parsing of the argument string. And yes, we need // from Cocoa doing its own parsing of the argument string. And yes, we need

View File

@ -66,10 +66,6 @@ CPPSRCS = \
nsSigHandlers.cpp \ nsSigHandlers.cpp \
$(NULL) $(NULL)
ifdef MOZ_INSTRUMENT_EVENT_LOOP
CPPSRCS += EventTracer.cpp
endif
ifdef MOZ_SPLASHSCREEN ifdef MOZ_SPLASHSCREEN
ifeq ($(OS_ARCH),WINCE) ifeq ($(OS_ARCH),WINCE)
CPPSRCS += nsSplashScreenWin.cpp CPPSRCS += nsSplashScreenWin.cpp

View File

@ -62,10 +62,6 @@ using mozilla::dom::ContentParent;
#include "nsAppRunner.h" #include "nsAppRunner.h"
#include "nsUpdateDriver.h" #include "nsUpdateDriver.h"
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
#include "EventTracer.h"
#endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
#include "MacLaunchHelper.h" #include "MacLaunchHelper.h"
#include "MacApplicationDelegate.h" #include "MacApplicationDelegate.h"
@ -3748,13 +3744,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
nativeApp->Enable(); nativeApp->Enable();
} }
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
bool event_tracing_running = false;
if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP")) {
event_tracing_running = mozilla::InitEventTracing();
}
#endif /* MOZ_INSTRUMENT_EVENT_LOOP */
NS_TIME_FUNCTION_MARK("Next: Run"); NS_TIME_FUNCTION_MARK("Next: Run");
NS_TIME_FUNCTION_MARK("appStartup->Run"); NS_TIME_FUNCTION_MARK("appStartup->Run");
@ -3774,11 +3763,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_TIME_FUNCTION_MARK("appStartup->Run done"); NS_TIME_FUNCTION_MARK("appStartup->Run done");
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
if (event_tracing_running)
mozilla::ShutdownEventTracing();
#endif
// Check for an application initiated restart. This is one that // Check for an application initiated restart. This is one that
// corresponds to nsIAppStartup.quit(eRestart) // corresponds to nsIAppStartup.quit(eRestart)
if (rv == NS_SUCCESS_RESTART_APP) if (rv == NS_SUCCESS_RESTART_APP)

View File

@ -46,17 +46,12 @@ MODULE = widget
XPIDL_MODULE = widget XPIDL_MODULE = widget
GRE_MODULE = 1 GRE_MODULE = 1
EXPORTS_NAMESPACES = IPC mozilla EXPORTS_NAMESPACES = IPC
EXPORTS_IPC = \ EXPORTS_IPC = \
nsGUIEventIPC.h \ nsGUIEventIPC.h \
$(NULL) $(NULL)
ifdef MOZ_INSTRUMENT_EVENT_LOOP
EXPORTS_mozilla = \
WidgetTraceEvent.h
endif
EXPORTS = \ EXPORTS = \
nsIWidget.h \ nsIWidget.h \
nsGUIEvent.h \ nsGUIEvent.h \

View File

@ -1,53 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef WIDGET_PUBLIC_WIDGETTRACEEVENT_H_
#define WIDGET_PUBLIC_WIDGETTRACEEVENT_H_
namespace mozilla {
// Fire a tracer event at the UI-thread event loop, and block until
// the event is processed. This should only be called by
// a thread that's not the UI thread.
bool FireAndWaitForTracerEvent();
// Signal that the event has been received by the event loop.
void SignalTracerThread();
}
#endif // WIDGET_PUBLIC_WIDGETTRACEEVENT_H_

View File

@ -1,51 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This file defines constants to be used in the "subtype" field of
* NSApplicationDefined type NSEvents.
*/
#ifndef WIDGET_COCOA_CUSTOMCOCOAEVENTS_H_
#define WIDGET_COCOA_CUSTOMCOCOAEVENTS_H_
// Empty event, just used for prodding the event loop into responding.
const short kEventSubtypeNone = 0;
// Tracer event, used for timing the event loop responsiveness.
const short kEventSubtypeTrace = 1;
#endif /* WIDGET_COCOA_CUSTOMCOCOAEVENTS_H_ */

View File

@ -60,41 +60,40 @@ EXPORTS = \
$(NULL) $(NULL)
CMMSRCS = \ CMMSRCS = \
nsBidiKeyboard.mm \ nsBidiKeyboard.mm \
nsClipboard.mm \ nsClipboard.mm \
nsMenuX.mm \ nsMenuX.mm \
nsMenuBarX.mm \ nsMenuBarX.mm \
nsMenuItemX.mm \ nsMenuItemX.mm \
nsMenuItemIconX.mm \ nsMenuItemIconX.mm \
nsMenuUtilsX.mm \ nsMenuUtilsX.mm \
nsMenuGroupOwnerX.mm \ nsMenuGroupOwnerX.mm \
nsFilePicker.mm \ nsFilePicker.mm \
nsDragService.mm \ nsDragService.mm \
nsToolkit.mm \ nsToolkit.mm \
nsAppShell.mm \ nsAppShell.mm \
nsCocoaUtils.mm \ nsCocoaUtils.mm \
nsCocoaWindow.mm \ nsCocoaWindow.mm \
nsChildView.mm \ nsChildView.mm \
nsWindowMap.mm \ nsWindowMap.mm \
nsWidgetFactory.mm \ nsWidgetFactory.mm \
nsCursorManager.mm \ nsCursorManager.mm \
nsMacCursor.mm \ nsMacCursor.mm \
nsScreenCocoa.mm \ nsScreenCocoa.mm \
nsScreenManagerCocoa.mm \ nsScreenManagerCocoa.mm \
nsSound.mm \ nsSound.mm \
nsLookAndFeel.mm \ nsLookAndFeel.mm \
nsNativeThemeCocoa.mm \ nsNativeThemeCocoa.mm \
nsDeviceContextSpecX.mm \ nsDeviceContextSpecX.mm \
nsPrintDialogX.mm \ nsPrintDialogX.mm \
nsPrintOptionsX.mm \ nsPrintOptionsX.mm \
nsPrintSettingsX.mm \ nsPrintSettingsX.mm \
nsIdleServiceX.mm \ nsIdleServiceX.mm \
nsCocoaTextInputHandler.mm \ nsCocoaTextInputHandler.mm \
nsMacDockSupport.mm \ nsMacDockSupport.mm \
nsStandaloneNativeMenu.mm \ nsStandaloneNativeMenu.mm \
GfxInfo.mm \ GfxInfo.mm \
WidgetTraceEvent.mm \ $(NULL)
$(NULL)
ifeq (x86_64,$(TARGET_CPU)) ifeq (x86_64,$(TARGET_CPU))
CMMSRCS += ComplexTextInputPanel.mm CMMSRCS += ComplexTextInputPanel.mm

View File

@ -1,92 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <Cocoa/Cocoa.h>
#include "CustomCocoaEvents.h"
#include <Foundation/NSAutoreleasePool.h>
#include <mozilla/CondVar.h>
#include <mozilla/Mutex.h>
#include "mozilla/WidgetTraceEvent.h"
using mozilla::CondVar;
using mozilla::Mutex;
using mozilla::MutexAutoLock;
namespace {
Mutex sMutex("Event tracer thread mutex");
CondVar sCondVar(sMutex, "Event tracer thread condvar");
bool sTracerProcessed;
}
namespace mozilla {
// This function is called from the main (UI) thread.
void SignalTracerThread()
{
MutexAutoLock lock(sMutex);
NS_ABORT_IF_FALSE(!sTracerProcessed, "Tracer synchronization state is wrong");
sTracerProcessed = true;
sCondVar.Notify();
}
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent()
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
MutexAutoLock lock(sMutex);
sTracerProcessed = false;
// Post an application-defined event to the main thread's event queue
// and wait for it to get processed.
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
location:NSMakePoint(0,0)
modifierFlags:0
timestamp:0
windowNumber:0
context:NULL
subtype:kEventSubtypeTrace
data1:0
data2:0]
atStart:NO];
while (!sTracerProcessed)
sCondVar.Wait();
[pool release];
return true;
}
} // namespace mozilla

View File

@ -43,8 +43,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <dlfcn.h> #include <dlfcn.h>
#include "CustomCocoaEvents.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsAppShell.h" #include "nsAppShell.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIFile.h" #include "nsIFile.h"
@ -171,27 +169,6 @@ PRBool nsCocoaAppModalWindowList::GeckoModalAboveCocoaModal()
return (topItem.mWidget != nsnull); return (topItem.mWidget != nsnull);
} }
// GeckoNSApplication
//
// Subclass of NSApplication for filtering out certain events.
@interface GeckoNSApplication : NSApplication
{
}
@end
@implementation GeckoNSApplication
- (void)sendEvent:(NSEvent *)anEvent
{
if ([anEvent type] == NSApplicationDefined &&
[anEvent subtype] == kEventSubtypeTrace) {
mozilla::SignalTracerThread();
return;
}
[super sendEvent:anEvent];
}
@end
// AppShellDelegate // AppShellDelegate
// //
// Cocoa bridge class. An object of this class is registered to receive // Cocoa bridge class. An object of this class is registered to receive
@ -309,7 +286,7 @@ nsAppShell::Init()
[NSBundle loadNibFile: [NSBundle loadNibFile:
[NSString stringWithUTF8String:(const char*)nibPath.get()] [NSString stringWithUTF8String:(const char*)nibPath.get()]
externalNameTable: externalNameTable:
[NSDictionary dictionaryWithObject:[GeckoNSApplication sharedApplication] [NSDictionary dictionaryWithObject:[NSApplication sharedApplication]
forKey:@"NSOwner"] forKey:@"NSOwner"]
withZone:NSDefaultMallocZone()]; withZone:NSDefaultMallocZone()];
@ -411,7 +388,7 @@ nsAppShell::ProcessGeckoEvents(void* aInfo)
timestamp:0 timestamp:0
windowNumber:0 windowNumber:0
context:NULL context:NULL
subtype:kEventSubtypeNone subtype:0
data1:0 data1:0
data2:0] data2:0]
atStart:NO]; atStart:NO];
@ -433,7 +410,7 @@ nsAppShell::ProcessGeckoEvents(void* aInfo)
timestamp:0 timestamp:0
windowNumber:0 windowNumber:0
context:NULL context:NULL
subtype:kEventSubtypeNone subtype:0
data1:0 data1:0
data2:0] data2:0]
atStart:NO]; atStart:NO];

View File

@ -62,24 +62,23 @@ ifdef ACCESSIBILITY
CSRCS += maiRedundantObjectFactory.c CSRCS += maiRedundantObjectFactory.c
endif endif
CPPSRCS = \ CPPSRCS = \
nsWindow.cpp \ nsWindow.cpp \
nsAppShell.cpp \ nsAppShell.cpp \
nsWidgetFactory.cpp \ nsWidgetFactory.cpp \
nsToolkit.cpp \ nsToolkit.cpp \
nsBidiKeyboard.cpp \ nsBidiKeyboard.cpp \
nsLookAndFeel.cpp \ nsLookAndFeel.cpp \
nsGtkKeyUtils.cpp \ nsGtkKeyUtils.cpp \
nsFilePicker.cpp \ nsFilePicker.cpp \
nsSound.cpp \ nsSound.cpp \
nsNativeKeyBindings.cpp \ nsNativeKeyBindings.cpp \
nsScreenGtk.cpp \ nsScreenGtk.cpp \
nsScreenManagerGtk.cpp \ nsScreenManagerGtk.cpp \
nsImageToPixbuf.cpp \ nsImageToPixbuf.cpp \
nsAccessibilityHelper.cpp \ nsAccessibilityHelper.cpp \
nsGtkIMModule.cpp \ nsGtkIMModule.cpp \
WidgetTraceEvent.cpp \ $(NULL)
$(NULL)
ifdef MOZ_X11 ifdef MOZ_X11
CPPSRCS += nsIdleServiceGTK.cpp CPPSRCS += nsIdleServiceGTK.cpp

View File

@ -1,86 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/WidgetTraceEvent.h"
#include <glib.h>
#include <mozilla/CondVar.h>
#include <mozilla/Mutex.h>
#include <stdio.h>
using mozilla::CondVar;
using mozilla::Mutex;
using mozilla::MutexAutoLock;
namespace {
Mutex sMutex("Event tracer thread mutex");
CondVar sCondVar(sMutex, "Event tracer thread condvar");
bool sTracerProcessed = false;
// This function is called from the main (UI) thread.
gboolean TracerCallback(gpointer data)
{
MutexAutoLock lock(sMutex);
NS_ABORT_IF_FALSE(!sTracerProcessed, "Tracer synchronization state is wrong");
sTracerProcessed = true;
sCondVar.Notify();
return FALSE;
}
} // namespace
namespace mozilla {
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent()
{
// Send a default-priority idle event through the
// event loop, and wait for it to finish.
MutexAutoLock lock(sMutex);
NS_ABORT_IF_FALSE(!sTracerProcessed, "Tracer synchronization state is wrong");
g_idle_add_full(G_PRIORITY_DEFAULT,
TracerCallback,
NULL,
NULL);
while (!sTracerProcessed)
sCondVar.Wait();
sTracerProcessed = false;
return true;
}
} // namespace mozilla

View File

@ -47,33 +47,32 @@ LIBRARY_NAME = widget_windows
LIBXUL_LIBRARY = 1 LIBXUL_LIBRARY = 1
CPPSRCS = \ CPPSRCS = \
nsWindow.cpp \ nsWindow.cpp \
nsWindowGfx.cpp \ nsWindowGfx.cpp \
nsWindowDbg.cpp \ nsWindowDbg.cpp \
nsAppShell.cpp \ nsAppShell.cpp \
nsToolkit.cpp \ nsToolkit.cpp \
nsFilePicker.cpp \ nsFilePicker.cpp \
nsScreenWin.cpp \ nsScreenWin.cpp \
nsScreenManagerWin.cpp \ nsScreenManagerWin.cpp \
nsLookAndFeel.cpp \ nsLookAndFeel.cpp \
nsUXThemeData.cpp \ nsUXThemeData.cpp \
nsNativeThemeWin.cpp \ nsNativeThemeWin.cpp \
nsWinGesture.cpp \ nsWinGesture.cpp \
nsIdleServiceWin.cpp \ nsIdleServiceWin.cpp \
nsSound.cpp \ nsSound.cpp \
nsIMM32Handler.cpp \ nsIMM32Handler.cpp \
WindowHook.cpp \ WindowHook.cpp \
WinTaskbar.cpp \ WinTaskbar.cpp \
TaskbarPreview.cpp \ TaskbarPreview.cpp \
TaskbarTabPreview.cpp \ TaskbarTabPreview.cpp \
TaskbarWindowPreview.cpp \ TaskbarWindowPreview.cpp \
TaskbarPreviewButton.cpp \ TaskbarPreviewButton.cpp \
JumpListBuilder.cpp \ JumpListBuilder.cpp \
JumpListItem.cpp \ JumpListItem.cpp \
GfxInfo.cpp \ GfxInfo.cpp \
WidgetTraceEvent.cpp \ $(NULL)
$(NULL)
ifdef MOZ_CRASHREPORTER ifdef MOZ_CRASHREPORTER
CPPSRCS += LSPAnnotator.cpp CPPSRCS += LSPAnnotator.cpp

View File

@ -1,148 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ted Mielczarek <ted.mielczarek@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Windows widget support for event loop instrumentation.
* See toolkit/xre/EventTracer.cpp for more details.
*/
#include <stdio.h>
#include <windows.h>
#include "mozilla/WidgetTraceEvent.h"
#include "nsAppShellCID.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMPtr.h"
#include "nsIAppShellService.h"
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
#include "nsIWidget.h"
#include "nsIXULWindow.h"
#include "nsAutoPtr.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsWindowDefs.h"
namespace {
// Used for signaling the background thread from the main thread.
HANDLE event_handle = NULL;
// We need a runnable in order to find the hidden window on the main
// thread.
class HWNDGetter : public nsRunnable {
public:
HWNDGetter() : hidden_window_hwnd(NULL) {}
HWND hidden_window_hwnd;
NS_IMETHOD Run() {
// Jump through some hoops to locate the hidden window.
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
nsCOMPtr<nsIXULWindow> hiddenWindow;
nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDocShell> docShell;
rv = hiddenWindow->GetDocShell(getter_AddRefs(docShell));
if (NS_FAILED(rv) || !docShell) {
return rv;
}
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(docShell));
if (!baseWindow)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWidget> widget;
baseWindow->GetMainWidget(getter_AddRefs(widget));
if (!widget)
return NS_ERROR_FAILURE;
hidden_window_hwnd = (HWND)widget->GetNativeData(NS_NATIVE_WINDOW);
return NS_OK;
}
};
HWND GetHiddenWindowHWND()
{
// Need to dispatch this to the main thread because plenty of
// the things it wants to access are main-thread-only.
nsRefPtr<HWNDGetter> getter = new HWNDGetter();
NS_DispatchToMainThread(getter, NS_DISPATCH_SYNC);
return getter->hidden_window_hwnd;
}
} // namespace
namespace mozilla {
// This function is called from the main (UI) thread.
void SignalTracerThread()
{
if (event_handle != NULL)
SetEvent(event_handle);
}
// This function is called from the background tracer thread.
bool FireAndWaitForTracerEvent()
{
// First, try to find the hidden window.
static HWND hidden_window = NULL;
if (hidden_window == NULL) {
hidden_window = GetHiddenWindowHWND();
}
if (hidden_window == NULL)
return false;
if (event_handle == NULL)
event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
// Post the tracer message into the hidden window's message queue,
// and then block until it's processed.
PostMessage(hidden_window, MOZ_WM_TRACE, 0, 0);
WaitForSingleObject(event_handle, INFINITE);
return true;
}
} // namespace mozilla

View File

@ -118,7 +118,6 @@
#include "prprf.h" #include "prprf.h"
#include "prmem.h" #include "prmem.h"
#include "mozilla/WidgetTraceEvent.h"
#include "nsIAppShell.h" #include "nsIAppShell.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#include "nsIDOMNSUIEvent.h" #include "nsIDOMNSUIEvent.h"
@ -4597,13 +4596,6 @@ LRESULT CALLBACK nsWindow::WindowProcInternal(HWND hWnd, UINT msg, WPARAM wParam
} }
} }
if (msg == MOZ_WM_TRACE) {
// This is a tracer event for measuring event loop latency.
// See WidgetTraceEvent.cpp for more details.
mozilla::SignalTracerThread();
return 0;
}
// Get the window which caused the event and ask it to process the message // Get the window which caused the event and ask it to process the message
nsWindow *someWindow = GetNSWindowPtr(hWnd); nsWindow *someWindow = GetNSWindowPtr(hWnd);

View File

@ -56,8 +56,6 @@
// A magic APP message that can be sent to quit, sort of like a QUERYENDSESSION/ENDSESSION, // A magic APP message that can be sent to quit, sort of like a QUERYENDSESSION/ENDSESSION,
// but without the query. // but without the query.
#define MOZ_WM_APP_QUIT (WM_APP+0x0300) #define MOZ_WM_APP_QUIT (WM_APP+0x0300)
// Used as a "tracer" event to probe event loop latency.
#define MOZ_WM_TRACE (WM_APP+0x0301)
// GetWindowsVersion constants // GetWindowsVersion constants
#define WIN2K_VERSION 0x500 #define WIN2K_VERSION 0x500