Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideData structuresReview how per-refresh EDID matching assigns stable, distinct monitor UUIDs, including connector selection and the fallback rules that preserve legacy UUIDs when matching is unambiguous.
Review UUID-plus-name monitor and configuration lookup, and duplicate-UUID name preservation, which establish the identity rules used by callers.
Uses of the APIReview the display-manager call sites that use UUID-plus-name lookup and primary selection, with UUID-only fallback for compatibility.
Review configuration-update paths that run duplicate-UUID migrations before normal UUID updates and persist any resulting changes.
ImplementationReview the migration planner and screen, user, and fill-mode rewriting logic, including its safeguards against ambiguous monitor mappings and its handling of competing saved layouts.
TestsReview regression coverage for UUID assignment, matching, lookup, primary selection, and randomized topology properties.
Review regression coverage for duplicate-UUID migration, safe rejection of ambiguous cases, and preservation of layouts and related settings.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 8 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="display1/util.go" line_range="440-441" />
<code_context>
+ continue
}
+
+ if connectorName == outputName {
+ exactMatches = append(exactMatches, connectorName)
+ } else {
+ otherMatches = append(otherMatches, connectorName)
</code_context>
<issue_to_address>
**Saved layouts lose monitor positions**
When a saved system layout contains identical-EDID monitors under their former shared UUID, `updateUuid` leaves these `|v1` UUIDs unmigrated or maps repeated UUIDs to the same first monitor, so `getSysScreenConfig` looks up a different monitor-set key and returns an empty config. The saved layout is not applied.
Migrate each entry with a duplicate old UUID to its corresponding connector-specific UUID before rebuilding the saved system-layout key.
Also at `display1/util.go:448`.
</issue_to_address>
### Comment 2
<location path="display1/util.go" line_range="440-441" />
<code_context>
+ continue
}
+
+ if connectorName == outputName {
+ exactMatches = append(exactMatches, connectorName)
+ } else {
+ otherMatches = append(otherMatches, connectorName)
</code_context>
<issue_to_address>
**Saved monitor positions are lost**
When a user upgrades with saved configs for identical-EDID monitors under their former shared UUID, `updateUuid` leaves some `|v1` UUIDs unchanged or maps repeated UUIDs to the first monitor, so `applySysMonitorConfigs` cannot match the other monitors’ saved configs or applies the first config’s position to them. The monitors are disabled or their saved positions are lost.
Migrate each saved monitor config to the corresponding connector-specific UUID using the monitor’s identity rather than UUID alone.
Also at `display1/manager.go:2447`.
</issue_to_address>
### Comment 3
<location path="display1/manager.go" line_range="1922" />
<code_context>
// TODO 这里为什么需要更新 Name?
updateSysMonitorConfigsName(configs, m.monitorMap)
- configs.setPrimary(primaryMonitor.uuid)
+ configs.setPrimaryByUuidAndName(primaryMonitor.uuid, primaryMonitor.Name)
}
</code_context>
<issue_to_address>
**Primary selection collapses monitor configs**
When the user changes the primary in Extend mode while multiple connected monitors share a UUID, `updateSysMonitorConfigsName` matches configs by UUID alone, so when identical-EDID monitors share a UUID it overwrites every saved config name with the first matching monitor’s name. `setPrimaryByUuidAndName` then saves those collapsed names, and `applySysMonitorConfigs` matches by UUID and name exactly, so the other monitors lose their configs and are disabled on a later apply.
Update config names by matching both UUID and the existing monitor name, or otherwise preserve the distinct names for configs with duplicate UUIDs.
</issue_to_address>
### Comment 4
<location path="display1/displayconf.go" line_range="721-722" />
<code_context>
+ }
+ }
+
+ // Name 不匹配时回退到旧行为,避免旧配置导致显示器被直接禁用。
+ return cfgs.getByUuid(uuid)
+}
+
</code_context>
<issue_to_address>
**Legacy configs still collapse**
When saved configs contain multiple entries with the same UUID and their names do not match the connected monitors, `getByUuidAndName` falls back to the first UUID match for each monitor, so monitors sharing a legacy UUID and having names that no longer match all receive the same saved position. `setPrimary` can also rewrite every such config’s name to the first matching monitor, leaving the saved configurations indistinguishable; apply then restores the overlap.
When UUID fallback finds multiple configs, preserve or resolve their per-monitor identity instead of applying the first entry to every monitor.
Also at `display1/manager.go:1922`.
</issue_to_address>
### Comment 5
<location path="display1/displayconf.go" line_range="731" />
<code_context>
- } else {
- mc.Primary = false
- }
+ mc.Primary = mc.UUID == uuid && (name == "" || mc.Name == name)
}
}
</code_context>
<issue_to_address>
**Mirror primary selection is lost**
When a saved mirror config is found by UUID fallback because its saved name differs from the connected monitor’s name, `getByUuidAndName` returns the UUID match, but `setPrimaryByUuidAndName` requires an exact UUID-and-name match and clears every config’s `Primary` flag. The mirror config loses its inherited primary and falls back to an unintended default primary.
Set the primary flag on the config returned by the UUID-and-name lookup, including when that lookup used its UUID fallback.
Also at `display1/manager.go:1714`.
</issue_to_address>
### Comment 6
<location path="display1/duplicate_uuid_test.go" line_range="74" />
<code_context>
+ edid := bytes.Repeat([]byte{0x78}, 128)
+ seen := make(map[string]string)
+ for _, connector := range []string{"DP-1", "DP-2", "DP-3", "DP-4"} {
+ uuid := getOutputUuid(connector, connector, edid)
+ if other, ok := seen[uuid]; ok {
+ t.Fatalf("connector %s and %s got the same UUID %s", other, connector, uuid)
</code_context>
<issue_to_address>
**Standard names are not verified**
When `getOutputUuid` uses the output name instead of the standard name for a valid EDID, testGetOutputUuidIdenticalEdidUsesDistinctStdNames passes the connector as both `name` and `stdName` on line 74, so `getOutputUuid` can ignore `stdName` and still produce distinct UUIDs from the distinct connector names; the test misses that regression.
Pass differing output and standard names, then assert the UUIDs reflect the standard names.
</issue_to_address>
### Comment 7
<location path="display1/duplicate_uuid_test.go" line_range="149" />
<code_context>
+ if got := monitors.GetByUuidAndNameOrUuid("duplicate-uuid", "DP-2"); got == nil || got.Name != "DP-2" {
+ t.Fatalf("GetByUuidAndNameOrUuid returned %+v, want DP-2", got)
+ }
+ if got := monitors.GetByUuidAndNameOrUuid("duplicate-uuid", "DP-9"); got == nil {
+ t.Fatal("GetByUuidAndNameOrUuid should fall back to UUID for unknown name")
+ }
</code_context>
<issue_to_address>
**Wrong duplicate fallback passes**
When the requested name is unknown and multiple monitors share the UUID, testMonitorsGetByUuidAndNameOrUuid only checks for non-nil on line 149, so returning the wrong monitor when the name is unknown and UUIDs are duplicated still passes; the compatibility fallback can select the wrong display.
Assert that the duplicate-UUID fallback returns the same monitor as the existing UUID-only lookup.
</issue_to_address>
### Comment 8
<location path="display1/duplicate_uuid_test.go" line_range="111" />
<code_context>
+ t.Fatal("getByUuidAndName should fall back to UUID for unknown name")
+ }
+
+ cfgs.setPrimaryByUuidAndName(uuid, "DP-2")
+ primaryCount := 0
+ for _, cfg := range cfgs {
</code_context>
<issue_to_address>
**Stale primary flags go undetected**
When a different config is already marked primary before selection, testSysMonitorConfigsGetByUuidAndName initializes every config with `Primary` false (lines 84–89), so an implementation that sets DP-2 primary but fails to clear an existing primary passes the count check at lines 113–123; callers can end up with multiple primary configs.
Initialize another config as primary before selection and assert that only DP-2 remains primary.
</issue_to_address>|
该PR暂时不合入,因为显示器EDID完全一致的情况,可能从驱动入手会更好一些,而不是在daemon侧做兼容。 |
4c853bd to
6c13a2a
Compare
…ayouts Generate display UUIDs from a per-refresh view of the current topology. All connected X outputs are resolved against a freshly read DRM connector list, so identical-EDID monitors no longer share a UUID and the result cannot depend on hotplug or daemon-restart history. Only outputs that really share a (stdName, EDID fingerprint) pair fall back to their X output name, exact port-name matches keep the legacy UUID, and a single monitor keeps its @connector UUID even when several connectors report the same EDID. Migrate legacy screens configs that were saved with duplicate UUIDs instead of resetting the user's layout. The migration matches the old UUIDs to the current monitors by the EDID fingerprint embedded in each UUID and by the saved output names; it rewrites the screen key, per-monitor UUIDs, OnlyOne entries and fill-mode keys, and refuses to migrate when counts or names are ambiguous. Add regression tests for hotplug/restart stability, monitor replacement, single-monitor multi-connector and duplicate-connector-name cases, randomized topology properties, and legacy duplicate-UUID config migration. Log: Identical-EDID monitors keep independent layouts across hotplug and daemon restart, and existing layouts are migrated instead of reset. Influence: 1. Identical-EDID monitors receive unique UUIDs; a given topology keeps the same UUIDs across hotplug and daemon restarts. 2. A single monitor keeps its legacy UUID even when several DRM connectors report the same EDID. 3. Screens configs saved with duplicate UUIDs are migrated to the new UUIDs when the monitor set and names are unambiguous. fix(display): 保证同 EDID 显示器身份稳定并迁移旧布局 每轮刷新基于当前拓扑重新解析所有 X 输出的标准 connector 名,相同 EDID 的 显示器不再共享 UUID,判定结果也不再依赖热插或 daemon 重启历史。仅当多个 输出确实共享 (标准名, EDID 指纹) 时才回退到 X output 名;端口名精确匹配的 输出保留旧 UUID;只有一台显示器时,即使多个 connector 报告同一 EDID 也保留 @connector 形式的旧 UUID。 新增旧配置迁移:对历史上因重复 UUID 而无法命中的 Screens 配置,按 UUID 中 携带的 EDID 指纹和配置里的输出名映射到当前显示器,重写屏幕 key、各显示器 UUID、OnlyOne 条目和填充模式 key;数量或名称无法唯一确定时放弃迁移,避免 把布局写到错误的显示器,也避免升级后布局被整体重置。 补充热插/重启稳定性、换接显示器、单屏多 connector、跨卡同名 connector、 随机拓扑属性以及旧重复 UUID 配置迁移的回归测试。 Log: 相同 EDID 显示器在热插和重启后保持独立布局,旧布局会迁移而不是重置。 Influence: 1. 相同 EDID 显示器获得唯一 UUID,同一拓扑在热插和重启后 UUID 不变。 2. 单屏在多个 connector 报告同一 EDID 时保留旧 UUID。 3. 重复 UUID 的旧屏幕配置在显示器集合与名称可唯一确定时迁移到新 UUID。 PMS: BUG-382483
a9a65cf to
926a02e
Compare
Monitors with identical EDID (same model and batch without a unique serial number) were all mapped to the first matching DRM connector by getStdMonitorName(), so they received the same UUID. Config lookup by UUID then always returned the first entry, collapsing every screen to the same X/Y and restoring the overlap after each apply or drag.
Prefer the X output name when matching the DRM connector. If the EDID matches multiple connectors and the output name cannot identify one, return an error so the caller falls back to the unique X output name. Match saved monitor configs by UUID + Name, with a UUID fallback for compatibility, when selecting the mirror primary and applying configs.
Add regression tests for identical EDIDs, ambiguous matches, unique non-exact matches, UUID + Name config lookup and primary selection.
Log: Identical-EDID monitors now get distinct UUIDs and keep their own positions.
Influence:
fix(display): 避免 EDID 相同的显示器生成重复 UUID
同型号同批次显示器可能没有唯一序列号,EDID 完全相同。
getStdMonitorName() 原来只按 EDID 返回第一个匹配的 DRM connector, 导致这些显示器生成相同 UUID。配置按 UUID 查找时永远命中第一条,
所有屏幕被写成相同的 X/Y,拖拽或 apply 后又恢复重叠。
改为优先用 X output 名称精确匹配 connector;EDID 匹配到多个
connector 且无法按名称区分时返回错误,由调用方回退到唯一的
X output 名称。同时在复制模式主屏选择和配置应用路径中优先按
UUID + Name 匹配,匹配不到再回退到原 UUID 逻辑,兼容旧配置。
补充相同 EDID、歧义匹配、唯一但名称不完全匹配、UUID + Name
配置查找和主屏选择的回归测试。
Log: EDID 相同的显示器现在会生成不同 UUID,并各自保持位置。
Influence:
PMS: BUG-382483
Summary by Sourcery
Keep identical-EDID monitors’ identities and saved display layouts distinct while retaining compatibility with existing configurations.
Bug Fixes:
Enhancements:
Tests: