Skip to content

fix(display): avoid duplicate UUIDs for identical EDID monitors - #1295

Open
Ivy233 wants to merge 1 commit into
linuxdeepin:release/2500from
Ivy233:fix/display-duplicate-edid-uuid
Open

Ivy233 wants to merge 1 commit into
linuxdeepin:release/2500from
Ivy233:fix/display-duplicate-edid-uuid

Conversation

@Ivy233

@Ivy233 Ivy233 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Monitors with identical EDID could be mapped to the first matching DRM connector and receive the same UUID. Since monitor configs were looked up by UUID alone, all matching monitors could receive the first entry's position and refresh rate, causing overlapping layouts after apply or drag.

Fix

  • Rebuild the connector view on every refresh. When an EDID fingerprint belongs to one connected X output, keep the legacy first-matching connector behavior. When it belongs to multiple X outputs, use each unique X output name instead of guessing connector ownership. This avoids duplicate UUIDs and removes connector probe/readiness and enumeration-order dependencies for the multi-output case.
  • Match monitor configs by UUID + Name, with a unique-geometry fallback for duplicate legacy UUIDs. Ambiguous entries no longer reuse the first config or disable a connected monitor.
  • Set mirror primary through the uniquely matched config pointer, avoiding a second stale-name lookup that could mark multiple entries as primary.
  • Conservatively migrate legacy duplicate-UUID configs: validate EDID fingerprint counts, map entries by Name or unique geometry, then rebuild Screens keys and update monitor UUIDs, OnlyOne entries, FillModes, and user configs. Unmappable legacy keys are retained; existing newer configs are not overwritten.

Compatibility and validation

  • Single-monitor and unique-EDID setups retain their previous UUID behavior.
  • Multi-output UUIDs no longer depend on connector probing progress or connector enumeration order.
  • Legacy migration is performed only when the mapping is unambiguous. Otherwise the legacy key is kept and the normal default-layout path is used; no guessed per-monitor mapping is applied.
  • go test ./display1/..., race tests, and go vet ./display1 pass.
  • A dual-DP identical-EDID machine passed coordinate swaps, forward/reverse 60/59.94 Hz mixing, ApplyChanges + Save + repeated daemon restarts, and Mirror legacy-config tests with exactly one primary. Validation used the master 5fa3628f build, whose display fix has the same patch-id as this release change. Four simultaneous 4K monitors have not yet been validated.

Log: Identical-EDID monitors receive distinct UUIDs and retain independent layouts across apply, save, and daemon restarts; safely mappable legacy layouts are migrated.

Influence:

  1. Multiple monitors with identical EDID get distinct UUIDs based on their X output names.
  2. Single-monitor and unique-EDID configurations keep their legacy UUID behavior.
  3. Legacy duplicate-UUID configs are migrated only when fingerprint, name, or geometry mapping is unambiguous; otherwise old keys are preserved.

PMS: BUG-382483


问题

多台显示器的 EDID 完全相同时,旧实现可能将它们映射到第一个匹配的 DRM connector,生成相同 UUID。应用配置时又只按 UUID 取第一条,导致多屏被写入同一组坐标和刷新率,拖拽或 ApplyChanges 后再次重叠。

修复

  • 每轮刷新重新读取 connector 视图。同一 EDID 指纹只有一台 X 输出时保留旧首候选行为;有多台 X 输出时统一使用各自唯一的 X output 名,不再猜测 connector 归属,避免重复 UUID,并消除多输出场景对 connector 探测进度和枚举顺序的依赖。
  • 配置按 UUID + Name 匹配,重复旧 UUID 可用唯一几何信息消歧;无法确定时不再复用第一条配置,也不会因此禁用物理连接的显示器。
  • Mirror 主屏按唯一命中的配置指针设置,避免过期 Name 的二次查找把多条配置同时设为主屏。
  • 保守迁移旧重复 UUID 配置:校验 EDID 指纹及数量,按 Name 或唯一几何信息映射,重建 Screens key,并同步显示器 UUID、OnlyOne、FillModes 和用户配置。无法安全映射的旧 key 保留,不覆盖已经存在的新配置。

兼容性与验证

  • 单屏和 EDID 唯一的场景保持原有 UUID 行为。
  • 多输出 UUID 不再受 connector 探测进度和枚举顺序影响。
  • 仅在映射明确时迁移旧配置;否则保留旧 key,走正常默认布局流程,不猜测显示器对应关系。
  • go test ./display1/...、race 测试及 go vet ./display1 均通过。
  • 双 DP 同 EDID 测试机已通过坐标交换、正反向 60/59.94 混频、ApplyChanges + Save + 多次 daemon 重启,以及 Mirror 旧配置专项,Primary 恰好一条。真机使用 master 5fa3628f 构建,显示修复补丁与本 release 提交的 patch-id 相同。四块 4K 屏整机尚未验收。

Log: 同 EDID 显示器获得独立 UUID,坐标和刷新率可分别保存并在重启后恢复;可安全映射的旧布局同步迁移。

Influence:

  1. 多台同 EDID 显示器按 X output 名获得不同 UUID。
  2. 单屏和 EDID 唯一的场景保持原有 UUID 行为。
  3. 旧重复 UUID 配置仅在指纹、Name 或几何映射明确时迁移,无法安全映射时保留旧 key。

PMS: BUG-382483

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Add UUID-and-name monitor lookup with UUID-only fallback so callers can distinguish identical-EDID displays without breaking stale-name configurations.

  • display1/monitor.go L560-571

Uses of the API

Use UUID-plus-name matching when applying monitor settings and selecting mirror primaries, and safely resolve the primary fill-mode monitor.

  • display1/manager.go L876-895, L2450-2466, L2495-2514 (+6 small edits)

Implementation

Assign stable UUIDs from each refresh's complete X-output and DRM-connector view, falling back to X names when identical EDIDs make connector identity ambiguous.

  • display1/util.go L218-229, L408-466 (+2 small edits)
  • display1/xorg.go L428-486, L512-536 (+4 small edits)

Migrate legacy duplicate-UUID screen and user settings only when EDID fingerprints and monitor identity can be mapped safely, preserving layouts, OnlyOne choices, and fill modes.

  • display1/displayconf.go L150-163, L210-218, L454-895 (+1 small edits)

Preserve distinct saved monitor names when a UUID is duplicated, and resolve configuration entries by name or unambiguous geometry before changing primary state.

  • display1/config.go L1, L43-56
  • display1/displayconf.go L1161-1265

Tests

Add regression and randomized tests for UUID assignment, duplicate-UUID lookup and primary behavior, migration safety, and compatibility fallbacks.

  • display1/duplicate_uuid_test.go L1-781
  • display1/manager_test.go L197-286
  • display1/migration_test.go L1-703
  • display1/stdname_property_test.go L1-83

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread display1/util.go Resolved
Comment thread display1/util.go Resolved
Comment thread display1/manager.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/duplicate_uuid_test.go Resolved
Comment thread display1/duplicate_uuid_test.go Resolved
Comment thread display1/duplicate_uuid_test.go Resolved
@Ivy233
Ivy233 marked this pull request as draft November 10, 2026 07:53
@Ivy233
Ivy233 force-pushed the fix/display-duplicate-edid-uuid branch 4 times, most recently from 4f91093 to 2e7ab04 Compare December 2, 2026 09:01
@Ivy233
Ivy233 marked this pull request as ready for review December 2, 2026 09:09
@Ivy233

Ivy233 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

试图关闭PR重开以重新触发sourcery-ai的评估。

@Ivy233 Ivy233 closed this Dec 2, 2026
@Ivy233 Ivy233 reopened this Dec 2, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 10 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="display1/displayconf.go" line_range="829" />
<code_context>
+			logger.Debugf("duplicate uuid user config %q already exists, keep legacy key %q for retry", newKey, key)
+			continue
+		}
+		cfg.Screens[newKey] = result
+		logger.Infof("migrate duplicate uuid user config to %q", newKey)
+		delete(cfg.Screens, key)
</code_context>
<issue_to_address>
**Older user preferences win migration**

When multiple legacy user-config keys migrate to the same current monitor key and contain different preferences, `UserConfig.migrateDuplicateUuidScreens` processes sorted legacy keys and installs the first result for a new key; later configs targeting that key are skipped. When multiple historical keys represent the same current monitor set, the lexically first key's user preferences become active even if another key is the relevant one, so users see the wrong saved preferences.

Resolve competing user-config candidates deterministically using an explicit preference-selection rule instead of letting sorted key order choose the active config.
</issue_to_address>

### Comment 2
<location path="display1/displayconf.go" line_range="817-818" />
<code_context>
+		for modeKey, modeCfg := range screenCfg {
+			if strings.HasPrefix(modeKey, KeyModeOnlyOnePrefix) {
+				oldUuid := strings.TrimPrefix(modeKey, KeyModeOnlyOnePrefix)
+				for _, monitor := range migration.groups[oldUuid] {
+					result[KeyModeOnlyOnePrefix+monitor.uuid] = modeCfg
+				}
+				continue
</code_context>
<issue_to_address>
**Saved only-one settings disappear**

When a migrated screen entry has an OnlyOne setting whose UUID is absent from its migration group, the migration loop adds no replacement and continues, then deletes the old screen entry, so users lose the saved setting.

Preserve the original OnlyOne entry when its UUID has no migration group.
</issue_to_address>

### Comment 3
<location path="display1/displayconf.go" line_range="159" />
<code_context>

-	needSave := m.userConfig.updateUuid(monitors)
+	needSave := m.userConfig.migrateDuplicateUuidScreens(monitors)
+	if m.userConfig.updateUuid(monitors) {
+		needSave = true
+	}
</code_context>
<issue_to_address>
**Partial topology deletes legacy layouts**

When a legacy duplicate-UUID key is rejected because fewer matching monitors are connected, but its old UUID still resolves to one of those monitors, `migrateDuplicateUuidScreens` rejects a legacy key when only a subset of its identical-EDID monitors is connected, but the subsequent `updateUuid` can still resolve the repeated legacy UUID to the one connected monitor, delete the old key, and move its config under a key containing that monitor’s UUID more than once. When the full monitor set reconnects, the original layout is no longer available under its expected key.

Keep rejected duplicate-UUID keys out of the ordinary UUID updater, or make that updater reject mappings where repeated UUIDs resolve to the same monitor.

Also at `display1/displayconf.go:213`.
</issue_to_address>

### Comment 4
<location path="display1/displayconf.go" line_range="681-682" />
<code_context>
+	case DisplayModeExtend:
+		modeCfg = screenCfg.Extend
+	case DisplayModeOnlyOne:
+		for _, config := range screenCfg.OnlyOneMap {
+			modeCfg = config
+			break
+		}
</code_context>
<issue_to_address>
**Wrong saved layout wins**

When multiple legacy keys map to the same new key while the display mode is OnlyOne and candidates have different OnlyOne entries, `scoreDuplicateUuidCandidate` scores an arbitrary `OnlyOneMap` entry instead of the one selected by `OnlyOneUuid`; map iteration can change which candidate wins, so migration restores the wrong saved layout.

Score the `OnlyOneMap` entry selected by `OnlyOneUuid` rather than the first entry encountered.
</issue_to_address>

### Comment 5
<location path="display1/displayconf.go" line_range="628-629" />
<code_context>
+			monitorCfg.UUID = monitor.uuid
+			monitorCfg.Name = monitor.Name
+			onlyOneMap[monitor.uuid] = config
+			if oldUuid == c.OnlyOneUuid {
+				result.OnlyOneUuid = monitor.uuid
+			}
+		}
</code_context>
<issue_to_address>
**Saved display selection is lost**

When a duplicate-UUID screen config has an `OnlyOneUuid` whose `OnlyOneMap` entry is absent or cannot be mapped, `migrateDuplicateUuid` leaves the legacy UUID in `OnlyOneUuid` while migrating the screen key, so `applyModeOnlyOne` cannot find the selected monitor and falls back to the default primary.

Do not migrate the screen key while its `OnlyOneUuid` cannot be mapped to a current monitor.

Also at `display1/displayconf.go:634-638`.
</issue_to_address>

### Comment 6
<location path="display1/displayconf.go" line_range="1113" />
<code_context>
+// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
 //
 // SPDX-License-Identifier: GPL-3.0-or-later

</code_context>
<issue_to_address>
**Saved monitor positions collapse**

When multiple saved monitor configs share a UUID and none of their names match the current monitor names, `getByUuidAndName` falls back to `getByUuid`, which returns the first config for each monitor, so `applySysMonitorConfigs` assigns the same saved position to multiple monitors.

Avoid the first-match UUID fallback when multiple configs share a UUID and no name matches.
</issue_to_address>

### Comment 7
<location path="display1/xorg.go" line_range="500-503" />
<code_context>
+
+	stdNames := make(map[string]string, len(resolved))
+	for name, r := range resolved {
+		if !r.exact && ownerCount[r.claim] > 1 {
+			logger.Debugf("monitor %v: std name %q and EDID shared by %d outputs, fall back to X output name",
+				name, r.claim.stdName, ownerCount[r.claim])
+			continue
+		}
+		stdNames[name] = r.claim.stdName
</code_context>
<issue_to_address>
**Connector probing changes monitor UUIDs**

When DRM connector EDIDs are only partially available during one refresh and become available on a later refresh, a second matching connector becomes readable after a refresh that fell back to X output names, so `assignStdNames` now emits connector-based UUIDs for those outputs. Configs saved under the fallback UUIDs are not covered by the duplicate-UUID migration, and callers lose the saved layout when the IDs change.

Keep UUID assignment stable across connector-probe readiness changes, or migrate configurations when a monitor’s UUID changes from an X-name fallback to a connector name.
</issue_to_address>

### Comment 8
<location path="display1/migration_test.go" line_range="212" />
<code_context>
+		t.Fatal("migrated screen config not found")
+	}
+	dp2UUID := getOutputUuid("DP-2", "", monitors[0].edid)
+	if screen.OnlyOneMap[dp2UUID] == nil {
+		t.Fatalf("OnlyOneMap keys = %v, want %q", keysOfModeConfigs(screen.OnlyOneMap), dp2UUID)
+	}
</code_context>
<issue_to_address>
**Only-one migration can stay stale**

When onlyOneMap migration leaves the nested monitor UUID unchanged, when migration updates an `OnlyOneMap` key but leaves its nested monitor UUID as the legacy UUID, `TestMigrateDuplicateUuidScreensOnlyOne` checks only the new key and selector, while `TestMigrateDuplicateUuidScreensOnlyOneByGeometry` checks the name and selector but not the UUID. Both pass although the migrated monitor config cannot be resolved by its new UUID.

Assert that each migrated OnlyOneMap entry’s nested monitor UUID equals the corresponding current monitor UUID.

Also at `display1/migration_test.go:497`.
</issue_to_address>

### Comment 9
<location path="display1/stdname_property_test.go" line_range="59" />
<code_context>
+		shuffled := make([]testOutput, len(outputs))
+		copy(shuffled, outputs)
+		rng.Shuffle(len(shuffled), func(i, j int) { shuffled[i], shuffled[j] = shuffled[j], shuffled[i] })
+		for name, uuid := range testOutputUuids(t, dir, shuffled) {
+			if uuids[name] != uuid {
+				t.Fatalf("iter %d: output %s UUID depends on enumeration order: %s vs %s",
</code_context>
<issue_to_address>
**Connector-order regression passes**

When the implementation depends on DRM connector enumeration order, when UUID resolution depends on DRM connector enumeration order, `TestAssignStdNamesRandomizedTopologyProperties` only shuffles owners at lines 56–59; its connector list stays fixed, so the UUID comparison still passes.

Run the resolver with the same connector slice in multiple shuffled orders and compare the UUIDs.
</issue_to_address>

### Comment 10
<location path="display1/duplicate_uuid_test.go" line_range="375" />
<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>
**Ignored standard name passes**

When `getOutputUuid` stops incorporating `stdName`, when `getOutputUuid` ignores `stdName` and uses only `name`, `TestGetOutputUuidIdenticalEdidUsesDistinctStdNames` still passes: line 375 varies both arguments, so `name` alone produces distinct UUIDs.

Hold `name` constant while varying `stdName`, or assert the exact UUIDs expected for each standard name.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/displayconf.go Resolved
Comment thread display1/xorg.go Resolved
Comment thread display1/migration_test.go Resolved
Comment thread display1/stdname_property_test.go Resolved
Comment thread display1/duplicate_uuid_test.go Resolved
@Ivy233
Ivy233 force-pushed the fix/display-duplicate-edid-uuid branch from 2e7ab04 to 8e74605 Compare December 2, 2026 10:30
@fly602
fly602 force-pushed the fix/display-duplicate-edid-uuid branch from 8e74605 to 4c697c3 Compare December 3, 2026 02:29
…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 配置迁移的回归测试。

Influence:
1. 相同 EDID 显示器获得唯一 UUID,同一拓扑在热插和重启后 UUID 不变。
2. 单屏在多个 connector 报告同一 EDID 时保留旧 UUID。
3. 重复 UUID 的旧屏幕配置在显示器集合与名称可唯一确定时迁移到新 UUID。

Log: 相同 EDID 显示器在热插和重启后保持独立布局,旧布局会迁移而不是重置。
PMS: BUG-382483
@Ivy233
Ivy233 force-pushed the fix/display-duplicate-edid-uuid branch from 4c697c3 to 3b27a72 Compare December 3, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants