Pick the connected network adapter instead of the first counter instance - #3273
Open
DerAlexmann wants to merge 1 commit into
Open
DerAlexmann wants to merge 1 commit into
DerAlexmann wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the network readings of the
--system-informationAPI landing on anadapter that carries no traffic, so
CurrentNetDown/CurrentNetUpstay at 0.Related: #2377, #2915
Problem
HardwareUsageService.InitializePerfCounters()takes the first instance of theNetwork Interfaceperformance counter category and never looks at any other:That instance is not necessarily a usable adapter, for two reasons.
Disconnected adapters are listed too. VPN, TAP and secondary NICs show up in
the same category and report 0 forever.
Adapter descriptions containing
#produce a phantom instance. Windowsappends
#2,#3. to disambiguate adapters whose description is alreadytaken - routine after a mainboard swap or a driver reinstall. But
#is also theseparator PDH uses for duplicate instance names, so a single adapter called
Realtek PCIe GbE Family Controller #2surfaces as two instances: a phantombase instance that always reads 0, plus the real one rendered as
Realtek PCIe GbE Family Controller _2.And the order between them is not stable. On the reporting machine - one
physical NIC, exactly one PnP device, one class instance, no leftover registry
entry -
GetNetworkCards()[0]returned the adapter that actually has a link in:So the phantom wins consistently in the player and it is a coin flip elsewhere.
Because the duplicate exists only in the counter namespace and not as a device,
users cannot fix it on their side.
Instance listing on that machine:
Fix
Choose the instance that reports a non-zero
Current Bandwidth- i.e. theadapter that actually has a link - and fall back to the previous behaviour when
no counter responds, so nothing regresses where this already worked.
Testing
Built from
v2.2.1.0with the patch applied, loaded against the dependency setLively ships in
plugins\webview2, and exercised on the affected machine:GetNetworkCards()[0](before), net472GetPrimaryNetworkCard()(after), net472GetNetworkCards()[0](before), net9.0GetPrimaryNetworkCard()(after), net9.0Measured throughput on that machine: phantom instance 0 B/s, real adapter
27_145 B/s down and 7_682 B/s up at the same moment.
exactly the old behaviour.
Note
The same positional assumption exists for the GPU (
SystemInfo.GetGpu()[0]),which is the other half of #2915. Left alone here to keep this change focused.