-
Notifications
You must be signed in to change notification settings - Fork 1
fix : 라이브액티비티 expanded·락스크린 타이머 HH:MM:SS 포맷으로 통일 #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,19 +33,25 @@ private struct LiveTimerText: View { | |
| var body: some View { | ||
| Group { | ||
| if state.isRunning, let epoch = state.timerStartEpoch { | ||
| // 실행 중: 시스템 클록 기반 네이티브 타이머 (JS 업데이트 불필요) | ||
| Text(Date(timeIntervalSince1970: epoch / 1000), style: .timer) | ||
| .monospacedDigit() | ||
| let startDate = Date(timeIntervalSince1970: epoch / 1000) | ||
| TimelineView(.periodic(from: .now, by: 1.0)) { tl in | ||
| let elapsed = max(0, Int(tl.date.timeIntervalSince(startDate))) | ||
| Text(formatExpanded(elapsed)) | ||
| .font(.custom("Lexend-SemiBold", size: fontSize)) | ||
| .kerning(kerning) | ||
| .foregroundColor(C.timerGreen) | ||
| .minimumScaleFactor(0.6) | ||
| .lineLimit(1) | ||
| } | ||
|
Comment on lines
+36
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } else { | ||
| // 일시정지: JS에서 받은 정적 값 표시 | ||
| Text(formatExpanded(state.elapsedSeconds)) | ||
| .font(.custom("Lexend-SemiBold", size: fontSize)) | ||
| .kerning(kerning) | ||
| .foregroundColor(C.timerGreen) | ||
| .minimumScaleFactor(0.6) | ||
| .lineLimit(1) | ||
| } | ||
| } | ||
| .font(.custom("Lexend-SemiBold", size: fontSize)) | ||
| .kerning(kerning) | ||
| .foregroundColor(C.timerGreen) | ||
| .minimumScaleFactor(0.6) | ||
| .lineLimit(1) | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimelineView사용에 따른 성능 및 동작 신뢰성 이슈TimelineView(.periodic(from: .now, by: 1.0))를 사용하여 매초마다 뷰를 업데이트하는 방식은 Live Activity(라이브 액티비티)에서 다음과 같은 심각한 문제를 유발할 수 있습니다.시스템 스로틀링(Throttling) 및 타이머 멈춤 현상
iOS는 배터리 절약을 위해 백그라운드 및 잠금 화면(특히 Always-On Display 상태)에서 WidgetKit의 렌더링 빈도를 엄격하게 제한합니다. 이로 인해
TimelineView가 매초마다 실행되지 않고 타이머가 멈추거나 초 단위가 건너뛰는 현상이 발생하여 사용자 경험을 해칠 수 있습니다.배터리 소모 증가
매초마다 뷰를 다시 그리는 작업은 시스템 리소스를 지속적으로 소모하게 만듭니다. 기존의
Text(Date, style: .timer)방식은 시스템이 자체적으로 렌더링을 최적화하여 처리하므로 배터리 소모가 거의 없습니다.코드 중복 발생
TimelineView가 도입되면서Group내부에Text가 아닌 일반View가 포함되게 되었습니다. 이로 인해Text전용 모디파이어인.kerning을 더 이상 공통Group에 적용할 수 없게 되어, 각 분기(if/else)의Text마다 모든 모디파이어를 중복해서 작성해야 하는 구조적 단점이 발생했습니다.💡 제안
HH:MM:SS포맷 통일이라는 시각적 요구사항보다 타이머의 정확성과 배터리 효율성이 더 중요하다면, 기존의 네이티브 타이머 스타일(style: .timer)을 유지하는 것을 강력히 권장합니다. 만약 기획상 포맷 통일이 필수적이라면, 위에서 언급한 스로틀링 및 배터리 소모 트레이드오프를 충분히 인지하고 진행해야 합니다.