mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-08 11:39:10 +11:00
Improve UI startup after runspace overhaul (#5056)
* perf: keep UI startup responsive * test: make favicon checks runner-safe * fix: qualify favicon visibility state * test: isolate favicon visibility fixture * fix: enforce total favicon deadline * fix: address favicon review feedback * fix: recognize disabled SSH firewall rule * perf: restore favicon download throughput * docs: allow public PR review uploads * perf: restore overlapping favicon loading
This commit is contained in:
@@ -24,7 +24,7 @@ function Invoke-WinUtilSSHServer {
|
||||
if ($null -eq $firewallRule) {
|
||||
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||
Write-Host "Firewall rule for OpenSSH Server created and enabled."
|
||||
} elseif (-not $firewallRule.Enabled) {
|
||||
} elseif ([int]$firewallRule.Enabled -eq 2) {
|
||||
Set-NetFirewallRule -Name 'sshd' -Enabled True
|
||||
Write-Host "Firewall rule for OpenSSH Server enabled."
|
||||
}
|
||||
|
||||
@@ -27,13 +27,15 @@ function Measure-WinUtilStep {
|
||||
[string]$Scope = "WinUtil"
|
||||
)
|
||||
|
||||
$isUIDiagnostic = $Scope -in @("UI", "Tab")
|
||||
$captureTiming = -not $isUIDiagnostic -or $sync.IsLocalCompile
|
||||
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
try {
|
||||
& $ScriptBlock
|
||||
} finally {
|
||||
$stopwatch.Stop()
|
||||
|
||||
if ($null -ne $sync.StepTimings) {
|
||||
if ($captureTiming -and $null -ne $sync.StepTimings) {
|
||||
$null = $sync.StepTimings.Add([pscustomobject]@{
|
||||
Scope = $Scope
|
||||
Step = $Name
|
||||
@@ -41,7 +43,10 @@ function Measure-WinUtilStep {
|
||||
})
|
||||
}
|
||||
|
||||
Write-WinUtilLog -Component $Scope -Message "timing: $Name took $($stopwatch.ElapsedMilliseconds) ms"
|
||||
if ($captureTiming) {
|
||||
$level = if ($isUIDiagnostic) { "DEBUG" } else { "INFO" }
|
||||
Write-WinUtilLog -Level $level -Component $Scope -Message "timing: $Name took $($stopwatch.ElapsedMilliseconds) ms"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +76,8 @@ function Write-WinUtilTimingSummary {
|
||||
[int]$StartIndex = 0
|
||||
)
|
||||
|
||||
if ($null -eq $sync.StepTimings) {
|
||||
$isUIDiagnostic = $Scope -in @("UI", "Tab")
|
||||
if (($isUIDiagnostic -and -not $sync.IsLocalCompile) -or $null -eq $sync.StepTimings) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,9 +96,10 @@ function Write-WinUtilTimingSummary {
|
||||
$measured = ($steps | Measure-Object -Property Milliseconds -Sum).Sum
|
||||
$total = if ($TotalMilliseconds -ge 0) { $TotalMilliseconds } else { $measured }
|
||||
|
||||
Write-WinUtilLog -Component $Scope -Message "timing summary: $($steps.Count) step(s), $measured ms measured of $total ms total"
|
||||
$level = if ($isUIDiagnostic) { "DEBUG" } else { "INFO" }
|
||||
Write-WinUtilLog -Level $level -Component $Scope -Message "timing summary: $($steps.Count) step(s), $measured ms measured of $total ms total"
|
||||
foreach ($step in ($steps | Sort-Object Milliseconds -Descending | Select-Object -First $Top)) {
|
||||
$share = if ($total -gt 0) { [int](($step.Milliseconds / $total) * 100) } else { 0 }
|
||||
Write-WinUtilLog -Component $Scope -Message "timing summary: $($step.Milliseconds) ms ($share%) $($step.Step)"
|
||||
Write-WinUtilLog -Level $level -Component $Scope -Message "timing summary: $($step.Milliseconds) ms ($share%) $($step.Step)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,14 +513,14 @@ Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sy
|
||||
})
|
||||
|
||||
$buildClock.Stop()
|
||||
Write-WinUtilLog -Component "UI" -Message "Interface built in $($buildClock.ElapsedMilliseconds) ms, showing the window."
|
||||
Write-WinUtilLog -Level "DEBUG" -Component "UI" -Message "Interface built in $($buildClock.ElapsedMilliseconds) ms, showing the window."
|
||||
Write-WinUtilTimingSummary -Scope "UI" -TotalMilliseconds $buildClock.ElapsedMilliseconds
|
||||
|
||||
# Input priority runs behind everything already queued, so this fires at the first moment
|
||||
# the window could actually service a click
|
||||
$sync["Form"].Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Input, [action]{
|
||||
$sinceStart = [int]((Get-Date) - $sync.StartedAt).TotalMilliseconds
|
||||
Write-WinUtilLog -Component "UI" -Message "timing: interface ready for input $sinceStart ms after start."
|
||||
Write-WinUtilLog -Level "DEBUG" -Component "UI" -Message "timing: interface ready for input $sinceStart ms after start."
|
||||
}) | Out-Null
|
||||
|
||||
$sync["Form"].ShowDialog() | Out-Null
|
||||
|
||||
@@ -32,6 +32,12 @@ function Write-WinUtilLog {
|
||||
[switch]$Detail
|
||||
)
|
||||
|
||||
# UI performance diagnostics are useful to developers but are too noisy for the release
|
||||
# transcript. Compile.ps1 stamps local builds so DEBUG output cannot leak into CI artifacts.
|
||||
if ($Level -eq "DEBUG" -and ($null -eq $sync -or -not $sync.IsLocalCompile)) {
|
||||
return
|
||||
}
|
||||
|
||||
if ($Level -eq "ERROR" -and -not $Detail -and $null -ne $sync.LoggedErrors) {
|
||||
$null = $sync.LoggedErrors.Add("[$Component] $Message")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user