[wdmaudiodev] Re: Is there a way to force clearing device property cache on device uninstallation?

  • From: "Gary Daniels" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "Gary.Daniels" for DMARC)
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Sat, 2 Feb 2019 21:28:02 +0000

I have a component that runs before, during, and first thing after the upgrade. 
I know when those phases happen, that's the easy part. The problem lies with 
first boot. During first boot AudioEndpointBuilder starts up and starts setting 
up all of the endpoints and migrating the user settings, while at the same time 
PNP is finalizing all of its upgrade work and getting all of the drivers to 
come up for the first time. Interfaces come and go, drivers come and go, 
AudioEndpointBuilder is not a PNP component and has no insight inside of PNP to 
know when to wait, no insight into why stuff is happening (beyond me meeting up 
with the person i know in PNP with questions, which happens regularly). In some 
cases AudioEndpointBuilder would start up before PNP completed migration, it 
would detect that the driver was missing, interpret that as a removal, and 
delete the user settings. In other cases, AudioEndpointBuilder would process an 
endpoint coming up, migrate the user settings to endpoints, only to have PNP 
remove the driver and re-enumerate it a short time later, causing the user 
settings to be lost.

I sincerely agree that on a real uninstall it does make sense to remove these 
keys. My problem is identifying when it's appropriate to delete them, and when 
it's not because it's a transient condition. The core problem here is that 
AudioEndpointBuilder and MMDevapi are legacy components that have been bolted 
onto the side of pnp and try to do PNP-like operations, but is not actually a 
PNP component. I've been working to detangle this spaghetti code (you may have 
noticed that audmigplugin has shrunken dramatically and mmci.dll is gone 
entirely), and working with the PNP team on real solutions. The retention of 
these settings is an area that needs additional work.

Regarding Matthew's recommendation, that's an unfortunate mistake. We were told 
by the PNP team to start using the DeviceInstall32 tag in the sysvad driver, 
but we were not told at the time that they had not intended for it to become 
public, simple miscommunication. It was never meant to be communicated broadly, 
it was only ever intended for testing. You won't find MSDN documentation for 
the tag. It has been removed from the sysvad sample driver. I cannot recommend 
the approach, it is not a supported feature and future support for it is 
uncertain.

I can give you a bit of insight into how AudioEndpointBuilder works, so 
hopefully you can understand what is going on and are better equipped to figure 
out what is going wrong when there are problems. Needing to do an uninstall and 
reinstall is a symptom of a larger problem, so how can I help with identifying 
the root cause, and help to fix those issues.

take a look at:
hklm\software\microsoft\windows\currentversion\mmdevices\audio\<flow>\<mmdevice 
id guid>\properties {840b8171-b0ad-410f-8581-cccc0382cfef},0.

This property key contains the string which is used for the comparison for 
settings migration. If you were to install two instances of your driver, you 
would see that portions of this key changes. Those portions are ignored during 
the migration comparison. The hardware id, if your device has one, and 
reference strings don't change, they are what is used for the comparison.

Regarding USB, yes, that is exactly what would happen. If the hardware id is 
the same and the reference strings are the same, whether you have devices from 
different vendors or two of the same device, then the settings will match and 
migration will have problems. That's true for all versions of windows, i have 
not yet had an opportunity to address that class of bugs, but I am aware of it.

-Gary

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx <wdmaudiodev-bounce@xxxxxxxxxxxxx> On 
Behalf Of Eugene Muzychenko
Sent: Saturday, February 2, 2019 1:51 AM
To: Gary Daniels <wdmaudiodev@xxxxxxxxxxxxx>
Subject: [wdmaudiodev] Re: Is there a way to force clearing device property 
cache on device uninstallation?

Hello Gary,

To you uninstall and reinstall, and OS upgrade are two different 
things. To AudioEndpointBuilder service, they are intermingled.

These processes are different not to me only, they are different by the 
essense. If is't really that bad, Endpoint Builder definitely should take OS 
upgrade process into account.

I accept your feedback that you preferred the prior behavior of the 
settings being deleted, but please understand that these changes were 
not done lightheartedly, they were done as a direct result of many 
user feedbacks and have been largely beneficial for users.

I can understand that that such behavior is a kind of workaround. But I cannot 
understand why such behavior should be considered as the only right.

I currently have no way to distinguish a user initiated uninstall from 
system initiated transient condition that is part of a driver update 
or OS upgrade.

It's very strange. I thought that OS upgrade process is a very specific state 
that can be identified by many signs. Maybe you mean that OS upgrade may be 
performed in the background, and user-initiated actions may be 
indistinguishable from system-initiated ones? If so, a way to trigger device 
entry deletion in MMDevice would be enough. Any device uninstaller could use it 
to ask Endpoint Builder to remove entries for the device being uninstalled.

0001 and 0002 are ignored, as those are generated instance numbers 
which change across OS and (some) driver updates depending on how the 
driver update package is made.

But why not to include device hardware IDs into the comparison?
Virtual devices have them as well as real ones.

The correct thing to do here is to use a unique reference string that 
correlates to the function of the device and is, preferably, unique 
enough to not get mixed up with other manufacturers

I'm afraid it will be too ugly because reference strings are intended to 
distinguish internal device functions, not variations of devices derived from 
the same basic version.

In my opinion, much more correct way is to use a hardware ID to create a 
specific branch in the ENUM\ROOT, as Matthew suggested:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.freelists.org%2Fpost%2Fwdmaudiodev%2FHow-to-sign-up-with-MS-with-the-Win10-driver-no-charge-attestment-option%2C21&amp;data=02%7C01%7CGary.Daniels%40microsoft.com%7C00f7676691a5487b30da08d688f40f30%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636846979224705153&amp;sdata=ft1z%2BCYA8Ttpn11yq0%2BUJyklvFUGzb64y5JNEc2mjA4%3D&amp;reserved=0

In such case, hardware ID becomes a part of the instance ID, as for PCI/USB 
devices, and all migration problems you mentioned should be avoided.

But, in any case, there should be a way to remove MMDevice entries that 
corresponds to a device being uninstalled permanently. Now MMDevice database 
grows indefinitely, it obviously is not a correct behavior.

Many USB audio devices are different in design but based on the same chip, so 
they may have the same VID/PID/MI, and most of them have no serial numbers. A 
user who changed endpoint names and/or other settings for a USB device, then 
thrown this device away, and connected a differently looking device based on 
the same chip several months later, may be greatly surprised by its actual 
settings.

For an application uninstaller, it is considered incorrect to unconditionally 
leave registry settings and/or profile configuration files, offering no way to 
delete them. A device uninstaller should have an opportunity to either delete 
the appropriate system/user properties from MMDevice, or keep them for further 
re-installation.

So I don't ask for changing the OS behavior by default. I'm only asking for a 
signal to Endpoint Builder to delete cached properties for a device that had 
already been uninstalled.

I had filed a proposal in the Feedback Hub but cannot retrieve the URL because 
my Win10 cannot connect to the service for an unknown reason.

Regards,
Eugene

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.wdmaudiodev.com%2F&amp;data=02%7C01%7CGary.Daniels%40microsoft.com%7C00f7676691a5487b30da08d688f40f30%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636846979224705153&amp;sdata=VodHZLh6iY4Thr4NLH3qULd%2BSs29fKSOXLFUebkS%2Fx0%3D&amp;reserved=0

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: