radj307 / volume-control

Specific-Application Volume Control Hotkeys for Windows.
https://radj307.github.io/volume-control
GNU General Public License v3.0
72 stars 6 forks source link

[BUG] Volume control starts but has no functionality with no GUI. #142

Closed KateReller closed 8 months ago

KateReller commented 8 months ago

Version Number

6.6.3

File

Portable (VolumeControl.exe)

Windows Version

Modified Windows 11 (Atlas OS)

Actual Behaviour

When Volume Control launches, no hotkeys function. When opening the GUI, the taskbar icon appears but there's no window to be seen.

Expected Behaviour

Volume control should launch with hotkey functionality and with a GUI.

Reproduction Steps

No response

Log

HH:mm:ss:fff              === Log Initialized @ Wednesday, December 13, 2023 1:18:00 AM ===  { LogFilter: 95 (DEBUG, INFO, WARN, ERROR, CRITICAL, TRACE) }
19:18:00:752  [INFO]      Config Path: "VolumeControl.json"
                          Log Path:    "VolumeControl.log"
19:18:00:761  [TRACE]     [LocalizationHelper] Reloading translation configs.
19:18:00:762  [DEBUG]     [LocalizationHelper] Loaded language "German (DE/DE)" with 98 translations.
19:18:00:764  [DEBUG]     [LocalizationHelper] Loaded language "English (US/CA)" with 309 translations.
19:18:00:764  [DEBUG]     [LocalizationHelper] Loaded language "Français (French)" with 79 translations.
19:18:00:766  [DEBUG]     [LocalizationHelper] Loaded language "Magyar (Hungarian)" with 286 translations.
19:18:00:768  [DEBUG]     [LocalizationHelper] Loaded language "Italiano (Italian)" with 309 translations.
19:18:00:769  [DEBUG]     [LocalizationHelper] Loaded language "Portuguese (Portugal)" with 79 translations.
19:18:00:769  [INFO]      Config version is 0.0.0, settings will be migrated to version 6.6.3.
19:18:00:960  [DEBUG]     [VCSettings] initializing...
19:18:01:034  [DEBUG]     [HwndSourceHookManager] Created hook manager for window handle "1509858".
19:18:01:035  [DEBUG]     [HwndSourceHookManager] Window handle is null; cannot add source hook: { Method: "VolumeControl.WPF.MessageHooks.WpfMaximizeBugFixHook.WndProcHook(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) => IntPtr", Target: "" }
19:18:01:035  [DEBUG]     [HwndSourceHookManager] Window handle is null; cannot add source hook: { Method: "VolumeControl.WPF.MessageHooks.WpfTiltScrollHook.WndProcHook(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) => IntPtr", Target: "" }
19:18:01:035  [DEBUG]     Executable location: 'C:\Users\Niflrosa\Desktop'
                          Working directory:   'C:\Users\Niflrosa\Desktop'
19:18:01:035  [INFO]      Volume Control version 6.6.3 (Portable)
19:18:01:067  [INFO]      Microsoft Windows 11 Pro (64-bit)
19:18:01:067  [DEBUG]     [VCSettings] initialization completed.
19:18:01:364  [DEBUG]     Started initializing CoreAudio APIs.
19:18:01:471  [CRITICAL]  An unhandled exception occurred in the application dispatcher!
                          Sender: "System.Windows.Threading.Dispatcher" (System.Windows.Threading.Dispatcher)
                          Thread: ""
                          {
                            "Message": "The invocation of the constructor on type 'VolumeControl.ViewModels.VolumeControlVM' that matches the specified binding constraints threw an exception."
                            "HResult": "-2146233087"
                            "ExceptionType": "System.Windows.Markup.XamlParseException"
                            "LineNumber": "0"
                            "LinePosition": "0"
                            "BaseUri": "pack://application:,,,/VolumeControl;component/app.xaml"
                            "Source": "PresentationFramework"
                            "TargetSite": {
                              "Name": "RewrapException"
                              "DeclaringType": "System.Windows.Markup.XamlReader"
                              "Attributes": "PrivateScope, Assembly, Static, HideBySig"
                              "CallingConvention": "Standard"
                            }
                            "Data": {
                              "System.Object": ""
                            }
                            "StackTrace": {
                              [0] at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
                              [1] at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
                              [2] at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
                              [3] at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
                              [4] at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
                              [5] at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
                              [6] at System.Windows.Application.DoStartup()
                              [7] at System.Windows.Application.<.ctor>b__1_0(Object unused)
                              [8] at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
                              [9] at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
                            }
                            "InnerException": {
                              "Message": "Element not found. (0x80070490)"
                              "HResult": "-2147023728"
                              "ExceptionType": "System.Runtime.InteropServices.COMException"
                              "ErrorCode": "-2147023728"
                              "Source": "System.Private.CoreLib"
                              "TargetSite": {
                                "Name": "ThrowExceptionForHR"
                                "DeclaringType": "System.Runtime.InteropServices.Marshal"
                                "Attributes": "PrivateScope, Public, Static, HideBySig"
                                "CallingConvention": "Standard"
                              }
                              "StackTrace": {
                                [0] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
                                [1] at CoreAudio.AudioSessionManager2.RefreshSessions()
                                [2] at CoreAudio.MMDevice.GetAudioSessionManager2()
                                [3] at CoreAudio.MMDevice.get_AudioSessionManager2()
                                [4] at VolumeControl.CoreAudio.AudioDevice..ctor(MMDevice mmDevice)
                                [5] at VolumeControl.CoreAudio.AudioDeviceManager.CreateAndAddDeviceIfUnique(MMDevice mmDevice)
                                [6] at VolumeControl.CoreAudio.AudioDeviceManager..ctor(DataFlow deviceDataFlow, MMDeviceEnumerator deviceEnumerator)
                                [7] at VolumeControl.CoreAudio.AudioDeviceManager..ctor(DataFlow deviceDataFlow)
                                [8] at VolumeControl.ViewModels.AudioDeviceManagerVM..ctor()
                                [9] at VolumeControl.ViewModels.VolumeControlVM..ctor()
                                [10] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
                              }
                            }
                          }
19:18:27:842  [INFO]      App exited with code 0
19:18:27:842  [TRACE]     Saved Config (Caller: "Main_Impl")
radj307 commented 8 months ago

Issue appears to be caused by something failing inside of CoreAudio.AudioSessionManager2.RefreshSessions()

Will investigate.

radj307 commented 8 months ago

Added a try-catch block around the CreateAndAddDeviceIfUnique call within the AudioDeviceManager constructor to log information about the offending device in 1e1bf1b5ddece929c490e834e940fafce44f0b7e. This should prevent the application from crashing (at least during initialization), but will also prevent whichever device caused the problem from being loaded. This is a worthy tradeoff since it wouldn't be possible to load that device anyway.

Pushing a new tag 6.6.4-rc1 for you to test, will provide an update shortly.

radj307 commented 8 months ago

UPDATE: The test version is available here. See this wiki page for download instructions. Ignore the update prompt if it appears.

Let me know if the issue persists for you when using that version.

KateReller commented 8 months ago

I do not see any issues with 6.6.4-rc1. Here's the log files. VolumeControl.log

However, I cannot recreate the issue on 6.6.3 anymore.

radj307 commented 8 months ago

From the provided log file, it appears that the issue didn't occur at all that time. This isn't too surprising, especially if you rebooted the machine between attempts. These kinds of issues are fickle, as the cause is dependent on internal Windows processes, your specific setup, and any number of other external variables.

Nonetheless, it's still a bug, and a critical one at that. Thank you for reporting, the changes I implemented should prevent this from happening in the future.

Closing this as completed, the fix will be included in the next full release.