Frosthaven / voicemeeter-windows-volume

Tray app that allows you to sync windows volume and mute state to Voicemeeter volume controls
265 stars 9 forks source link

Random Freezing w/Possible Solution #36

Open Mineral opened 1 year ago

Mineral commented 1 year ago

So I've noticed that the application seems to occasionally freeze and although I'll get an onscreen notification that the volume is being changed, my VMeeter outputs will not change. When this occurs, the VMWV icon in the taskbar becomes transparent and I am unable to launch it's context menu by clicking it.

I'm running Windows 10 Version 22H2 (Build 19045.2846). The file version of VMWV.exe is 16.12.0.0.

I was curious if this freeze was related to the .vbs script used to launch it, as I've seen similar issues in the past from .exe files started via .vbs scripts, so I created simple a PowerShell script and added it to my Task Scheduler, replacing the voicemeeter-windows-volume task.

It checks for any running instances of VMWV.exe and stops them before starting a fresh instance, so it works as a 'refresher', should I notice that VMWV.exe has frozen; when I originally made the script, the intention was for it to occasionally run in order to restart VMWV.exe should it have frozen... except that I noticed that since launching VMWV.exe via this powershell script instead of the .vbs file, it hadn't frozen at all. I've left in a couple of diagnostic messages; I figured if this script was useful to you, you'd adapt it as you see fit. It should run with no complications on any Windows 10 or Windows 11 install.

Add-Type -AssemblyName PresentationFramework

function Show-MessageBox {
    param(
        [string]$Message
    )

    [System.Windows.MessageBox]::Show($Message, "Error", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
}

$scriptDir = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$vmwvPath = Join-Path -Path $scriptDir -ChildPath "required\VMWV.exe"

try {
    Get-Process -Name "VMWV" -ErrorAction SilentlyContinue | Stop-Process -Force
    Write-Host "Successfully stopped existing VMWV instance(s)."
} catch {
    Show-MessageBox "Failed to stop existing VMWV instance. Error: $_"
}

try {
    Start-Process -FilePath $vmwvPath -Verb RunAs -WindowStyle Hidden
    Write-Host "Successfully started VMWV!"
} catch {
    Show-MessageBox "Failed to start VMWV. Error: $_"
}
Frosthaven commented 1 year ago

This is curious - I haven't had the app freeze at all. Once it starts up, it mostly uses an invisible powershell thread to do its work - so as long as it starts properly it should be fine and happy to truck along.

I know that a windows update has caused the "launch at startup" to enter into a race condition where it doesn't start correctly. Is this what you experienced? Or would yours start correctly and then hang some time later?

Mineral commented 1 year ago

I know that a windows update has caused the "launch at startup" to enter into a race condition where it doesn't start correctly. Is this what you experienced? Or would yours start correctly and then hang some time later?

The latter; it would work normally for an amount of time, then at some point I would notice the Windows OSD volume display wasn't matching up with the VoiceMeeter volume (which would be on whatever level it was when VMWV froze), check the taskbar notification area and see an empty space where the VMWV logo would normally be. Does VMWV do any form of logging, or other diagnostic information I'd be able to share?

Frosthaven commented 1 year ago

for full logging support, you can open an admin command line / powershell in the folder with VMWV and run ./VMWV.exe, which will launch the app in the console and give complete logging output :)

Mineral commented 1 year ago

Great! I was unsure if you'd put output messages in the application - I didn't even think to check, honestly - so that will hopefully shed some light on the issue.

Edit: Right, then. Let's see if this works! (The log included is for demo purposes, I'll post another reply in this thread when (if?) VMMV freezes again.)

[ INFO ] 2023-05-04 14:15:14 - Voicemeeter Windows Volume started, Process ID:  10148
[ INFO ] 2023-05-04 14:15:15 - Using settings file: C:\Users\Craig Jessup\OneDrive\Utilities (Standalone)\Voicemeeter Windows Volume\required\settings.json
[ INFO ] 2023-05-04 14:15:15 - Starting audio synchronization
[ INFO ] 2023-05-04 14:15:15 - Process found: voicemeeter.exe
[ INFO ] 2023-05-04 14:15:18 - Voicemeeter: Fully Initialized
[ INFO ] 2023-05-04 14:15:18 - Started Powershell worker "AudioScanner" with process ID of  12276
[ INFO ] 2023-05-04 14:15:18 - Started Powershell worker "DeviceScanner" with process ID of  46316
[ INFO ] 2023-05-04 14:15:19 - Set initial volume to 16%
[ INFO ] 2023-05-04 14:15:23 - remembering volume: 14
[ INFO ] 2023-05-04 14:15:23 - remembering volume: 12
[ INFO ] 2023-05-04 14:15:23 - remembering volume: 10
[ INFO ] 2023-05-04 14:15:23 - remembering volume: 12
[ INFO ] 2023-05-04 14:15:24 - remembering volume: 14
Frosthaven commented 1 year ago

The latest release now uses PowerShell exclusively for the start with windows functionality. The self-diagnostic startup is inspired in part by some of the scripting you've done here.

Great stuff! Let me know how the new version fairs for you!

Mineral commented 1 year ago

Oh, very cool! I've not actually had the freezing issue since setting up logging, so I'll just stop doing that for now and see what the new version is like! :)