fix(charts): 修复浮窗层级并平滑切频与曲线移出
This commit is contained in:
@@ -16,6 +16,22 @@ import Foundation
|
||||
precondition(PanelCurveGeometry.runs(dates: slow, values: [0.1, 0.2, 0.3], maximumGap: 3600).count == 1)
|
||||
precondition(PanelCurveGeometry.runs(dates: slow, values: [0.1, 0.2, 0.3], maximumGap: 3600, boundaryDates: [slow[1]]).count == 2)
|
||||
precondition(PanelCurveGeometry.isAppend(from: Array(slow.prefix(2)), to: slow, maximumGap: 3600))
|
||||
print("PASS: timestamp append/full history, pause/reset, missing/nonfinite data, short series and disconnected curves")
|
||||
precondition(PanelCurveGeometry.runs(dates: slow, values: [0.1, 0.2, 0.3], maximumGap: 5, intervals: [1800, 1800, 0.5]).count == 1)
|
||||
precondition(PanelCurveGeometry.runs(dates: slow, values: [0.1, 0.2, 0.3], maximumGap: 5, boundaryDates: [slow[2]], intervals: [1800, 1800, 0.5]).count == 2)
|
||||
let old = PanelCurveFrame(dates: dates, series: [Array(repeating: 0.3, count: 60), []], intervals: Array(repeating: 2, count: 60), boundaryDates: [])
|
||||
let next = PanelCurveFrame(dates: Array(dates.dropFirst()) + [dates.last!.addingTimeInterval(2)], series: [Array(repeating: 0.3, count: 59) + [0.4], []], intervals: Array(repeating: 2, count: 60), boundaryDates: [])
|
||||
let transition = PanelCurveFrame.transition(from: old, to: next)
|
||||
precondition(transition.dates.count == 61 && transition.dates.first == old.dates.first)
|
||||
precondition(transition.series[0].first! == 0.3 && transition.series[0].last! == 0.4 && transition.series[1].isEmpty)
|
||||
precondition(Array(transition.series[0].prefix(60)) == old.series[0])
|
||||
for progress in [0.0, 0.25, 0.5, 0.75, 1.0] {
|
||||
let domain = PanelCurveFrame.domain(previousBegin: old.dates.first, previousEnd: old.dates.last,
|
||||
begin: next.dates.first!, end: next.dates.last!, progress: progress)
|
||||
let left = domain.position(transition.dates[0]), right = domain.position(transition.dates[1])
|
||||
precondition(left <= 0 && right >= 0, "Outgoing segment must cover the left boundary throughout the animation")
|
||||
if progress == 0 { precondition(abs(left) < 0.000001 && abs(domain.position(old.dates.last!) - 1) < 0.000001) }
|
||||
if progress == 1 { precondition(abs(right) < 0.000001 && abs(domain.position(next.dates.last!) - 1) < 0.000001) }
|
||||
}
|
||||
print("PASS: timestamp append/full history, pause/reset, missing/nonfinite data, short series, cadence continuity, pause boundaries and 61-point left-edge animation geometry")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ swiftc -parse-as-library -module-cache-path /private/tmp/kymo-unified-cache \
|
||||
|
||||
```bash
|
||||
swiftc -module-cache-path /private/tmp/kymo-check-cache \
|
||||
kymo/UI/Charts/PanelCurveGeometry.swift kymoTests/PanelCurveChecks.swift \
|
||||
kymo/UI/Charts/PanelCurveGeometry.swift kymo/UI/Charts/PanelCurveFrame.swift kymoTests/PanelCurveChecks.swift \
|
||||
-o /private/tmp/kymo-panel-curve-checks
|
||||
/private/tmp/kymo-panel-curve-checks
|
||||
```
|
||||
|
||||
@@ -33,6 +33,8 @@ import Foundation
|
||||
precondition(store.snapshot.date == hiddenDate && store.snapshot.processes == nil)
|
||||
preferences.backgroundMilliseconds = 500
|
||||
try await until { store.snapshot.date > hiddenDate }
|
||||
precondition(store.history.samples.last?.breakBefore == false)
|
||||
precondition(store.history.samples.last?.expectedInterval == 0.5)
|
||||
let first = store.snapshot.date
|
||||
try await until { store.snapshot.date > first }
|
||||
precondition(store.snapshot.date.timeIntervalSince(first) >= 0.45)
|
||||
@@ -62,6 +64,19 @@ import Foundation
|
||||
precondition(didDeliver, "Reopened process request must complete without another sample")
|
||||
precondition(probe.count >= 2 && probe.peak == 1)
|
||||
await deferred.setProcessVisible(false)
|
||||
let slowRead = DelayedProcessRead(delay: 0.5)
|
||||
let changing = SamplingPreferences(defaults: defaults)
|
||||
changing.panelMilliseconds = 500
|
||||
changing.backgroundMilliseconds = 1_800_000
|
||||
let changingStore = MetricsStore(sampling: changing, sampler: SystemSampler(processRead: { slowRead.read(&$0) }))
|
||||
changingStore.setPanelVisible(true)
|
||||
try await until { !changingStore.history.samples.isEmpty }
|
||||
precondition(changingStore.snapshot.processes == nil)
|
||||
let countBeforeChange = changingStore.history.samples.count
|
||||
changing.panelMilliseconds = 1_800_000
|
||||
try await until { changingStore.snapshot.processes != nil }
|
||||
precondition(changingStore.history.samples.count == countBeforeChange, "Rate changes must preserve in-flight process delivery without an extra quick sample")
|
||||
changingStore.togglePause()
|
||||
print("PASS: defaults, 100ms quantization/clamping, independent persistence, invalid defaults, active/background wake, pause precedence, slow-interval initial processes and history boundary")
|
||||
}
|
||||
@MainActor private static func until(_ predicate: () -> Bool) async throws {
|
||||
@@ -78,6 +93,8 @@ private actor ProcessDelivery {
|
||||
|
||||
private final class DelayedProcessRead: @unchecked Sendable {
|
||||
private let lock = NSLock()
|
||||
private let delay: TimeInterval
|
||||
init(delay: TimeInterval = 0.2) { self.delay = delay }
|
||||
private var active = 0
|
||||
private var reads = 0
|
||||
private var maximum = 0
|
||||
@@ -86,7 +103,7 @@ private final class DelayedProcessRead: @unchecked Sendable {
|
||||
func read(_ monitor: inout ProcessMonitor) -> ProcessSnapshot {
|
||||
lock.lock(); active += 1; reads += 1; maximum = max(maximum, active); lock.unlock()
|
||||
defer { lock.lock(); active -= 1; lock.unlock() }
|
||||
Thread.sleep(forTimeInterval: 0.2)
|
||||
Thread.sleep(forTimeInterval: delay)
|
||||
return monitor.sample()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user