diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2019-09-17 22:03:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 22:03:13 +0300 |
commit | 9033e0ae39685a42742b18b4dc3e5269e9f8ee1b (patch) | |
tree | 06404d0cb255039415c8340b67e7d40d1f31e902 /main/src | |
parent | b34ccb052df4c7d0995af032601eab6342928f33 (diff) | |
parent | 8ac1a495c52afc2cace6a9601dca2e910f0e9c42 (diff) |
Merge pull request #8635 from mono/performance-diagnostics-lazy
[PerformanceDiagnostics] Move the gtk leak tracking handler under feature switch
Diffstat (limited to 'main/src')
6 files changed, 20 insertions, 69 deletions
diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs index 0c551a7f8d..54dee68d2b 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Commands.cs @@ -131,18 +131,12 @@ namespace PerformanceDiagnosticsAddIn { protected override void Run () { - if (!Options.HasMemoryLeakFeature) - return; - var type = typeof (GLib.Object).Assembly.GetType ("GLib.PointerWrapper"); if (type == null) { return; } - LoggingService.LogInfo ("Gtk/Mac leak tracking enabled"); - - if (Options.HasMemoryLeakFeaturePad) - LoggingService.LogInfo ("Gtk/Mac leak tracking pad enabled. May cause performance issues."); + LoggingService.LogInfo ("Gtk/Mac leak tracking enabled. May cause performance issues."); var field = type.GetField ("ObjectCreated", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); field.SetValue (null, new Action<IntPtr> (arg => { @@ -161,11 +155,6 @@ namespace PerformanceDiagnosticsAddIn class DumpLiveWidgetsHandler : CommandHandler { static readonly System.IO.TextWriter log = LoggingService.CreateLogFile ("leak-dump"); - protected override void Update (CommandInfo info) - { - info.Visible = Options.HasMemoryLeakFeature; - base.Update (info); - } protected override async void Run () { diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/LeakTrackerEnabledCondition.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/LeakTrackerEnabledCondition.cs deleted file mode 100644 index 4679fd5f93..0000000000 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/LeakTrackerEnabledCondition.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// LeakTrackerEnabledCondition.cs -// -// Author: -// Marius Ungureanu <maungu@microsoft.com> -// -// Copyright (c) 2017 2017 -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; -using Mono.Addins; - -namespace PerformanceDiagnosticsAddIn -{ - public class LeakTrackerEnabledCondition : ConditionType - { - public override bool Evaluate (NodeElement conditionNode) - { - if (conditionNode.GetAttribute ("value") == "pad") - return Options.HasMemoryLeakFeaturePad; - return Options.HasMemoryLeakFeature; - } - } -} diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Options.cs b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Options.cs index fd072e580b..5abae2e488 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Options.cs +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Options.cs @@ -32,9 +32,6 @@ namespace PerformanceDiagnosticsAddIn { public static readonly ConfigurationProperty<string> OutputPath = ConfigurationProperty.Create ("PerformanceDiagnosticsAddIn.OutputPath", System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Desktop")); //public static readonly ConfigurationProperty<bool> ShowUICounters = ConfigurationProperty.Create ("PerformanceDiagnosticsAddIn.ShowUICounters", false); - - public static readonly bool HasMemoryLeakFeature = System.IO.File.Exists (System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "xs-enable-leak-check")); - public static readonly bool HasMemoryLeakFeaturePad = HasMemoryLeakFeature && System.IO.File.Exists (System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "xs-enable-leak-check-pad")); } } diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj index 48126e5c14..59b6af744f 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/PerformanceDiagnosticsAddIn.csproj @@ -26,12 +26,11 @@ <Compile Include="Options.cs" /> <Compile Include="LeakHelpers.cs" /> <Compile Include="LeakTrackerPad.cs" /> - <Compile Include="LeakTrackerEnabledCondition.cs" /> <Compile Include="LeakSummaryService.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Properties\PerformanceDiagnostics.addin.xml" /> - <EmbeddedResource Include="Properties\ReliabilityDiagnostics.addin.xml" Condition=" '$(Configuration)' == 'Debug' "/> + <EmbeddedResource Include="Properties\ReliabilityDiagnostics.addin.xml" Condition=" '$(Configuration)' == 'Debug' " /> </ItemGroup> <ItemGroup> <IncludeCopyLocal Include="UIThreadMonitorDaemon.exe" /> diff --git a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/PerformanceDiagnostics.addin.xml b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/PerformanceDiagnostics.addin.xml index e6da7e12a6..79dbe54d24 100644 --- a/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/PerformanceDiagnostics.addin.xml +++ b/main/src/addins/PerformanceDiagnostics/PerformanceDiagnostics/Properties/PerformanceDiagnostics.addin.xml @@ -1,7 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <ExtensionModel> - <ConditionType id="LeakTrackerEnabled" type="PerformanceDiagnosticsAddIn.LeakTrackerEnabledCondition" /> - <Extension path="/MonoDevelop/Ide/Commands"> <Command id="PerformanceDiagnosticsAddIn.StartStopListeningUIThreadMonitorHandler" defaultHandler="PerformanceDiagnosticsAddIn.StartStopListeningUIThreadMonitorHandler" @@ -30,12 +28,19 @@ <CommandItem id="PerformanceDiagnosticsAddIn.ProfileFor5SecondsHandler" /> <CommandItem id="PerformanceDiagnosticsAddIn.ToggleProfileHandler" /> <CommandItem id="PerformanceDiagnosticsAddIn.EnhanceSampleFile" /> - <CommandItem id="PerformanceDiagnosticsAddIn.DumpLiveWidgetsHandler" /> <CommandItem id="PerformanceDiagnosticsAddIn.SpinDumpFor5SecondsHandler" /> </ItemSet> + + <Condition id="FeatureSwitch" name="WidgetLeaks" optIn="true"> + <ItemSet id="Diagnostics" _label="_Diagnostics"> + <CommandItem id="PerformanceDiagnosticsAddIn.DumpLiveWidgetsHandler" /> + </ItemSet> + </Condition> </Extension> <Extension path="/MonoDevelop/Ide/PreStartupHandlers"> - <Class class="PerformanceDiagnosticsAddIn.InitializeGtkHelperHandler" /> + <Condition id="FeatureSwitch" name="WidgetLeaks" optIn="true"> + <Class class="PerformanceDiagnosticsAddIn.InitializeGtkHelperHandler" /> + </Condition> </Extension> <Extension path="/MonoDevelop/Ide/GlobalOptionsDialog"> <Section id="PerformanceDiagnostics" @@ -50,20 +55,17 @@ </Extension> <Extension path = "/MonoDevelop/Ide/Pads"> - <Condition id="LeakTrackerEnabled" value="pad"> + <Condition id="FeatureSwitch" name="WidgetLeaks" optIn="true"> <Pad id = "PerformanceDiagnosticsAddIn.LeakTrackerPad" _label="Leak Tracker" icon="md-errors-list" group="Logs" - class = "PerformanceDiagnosticsAddIn.LeakTrackerPad" - defaultPlacement = "Bottom" - defaultStatus="AutoHide" - defaultLayout="*"/> + class = "PerformanceDiagnosticsAddIn.LeakTrackerPad"/> </Condition> </Extension> <Extension path="/MonoDevelop/Ide/WorkbenchLayouts/Solution"> - <Condition id="LeakTrackerEnabled" value="pad"> + <Condition id="FeatureSwitch" name="WidgetLeaks" optIn="true"> <LayoutPad id="PerformanceDiagnosticsAddIn.LeakTrackerPad" status="AutoHide" /> </Condition> </Extension> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.FeatureConfiguration/FeatureSwitchCondition.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.FeatureConfiguration/FeatureSwitchCondition.cs index 402ce4d164..cf339f7d70 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.FeatureConfiguration/FeatureSwitchCondition.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.FeatureConfiguration/FeatureSwitchCondition.cs @@ -29,7 +29,7 @@ using Mono.Addins; namespace MonoDevelop.Core.FeatureConfiguration { - public class FeatureSwitchCondition : ConditionType + class FeatureSwitchCondition : ConditionType { public override bool Evaluate (NodeElement conditionNode) { @@ -38,7 +38,11 @@ namespace MonoDevelop.Core.FeatureConfiguration return true; } - return FeatureSwitchService.IsFeatureEnabled (featureName) ?? true; + bool enabledByDefault = true; + if (bool.TryParse (conditionNode.GetAttribute ("optIn"), out bool optIn)) + enabledByDefault = !optIn; + + return FeatureSwitchService.IsFeatureEnabled (featureName) ?? enabledByDefault; } } } |