Repository navigation
Fix blank recording Live Activities on the lock screen #150
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/usr/bin/env python3 | ||
| """Check real WidgetKit archived layout, which an ImageRenderer preview cannot validate.""" | ||
| import math | ||
| import os | ||
| from pathlib import Path | ||
| import re | ||
| import signal | ||
| import subprocess | ||
| import sys | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
|
|
||
|
|
||
| def validate_render(text, activity_id): | ||
| entries = re.split(r"(?m)(?=^\d{4}-\d{2}-\d{2} \d{2}:)", text) | ||
| rendered = [entry for entry in entries | ||
| if f"[activity:{activity_id}:" in entry | ||
| and "Rendering view: AnyView(_ArchivedView" in entry] | ||
| for presentation in ("listItem", "dynamicIsland-compactTrailing"): | ||
| if not any(f"-{presentation}] Rendering view:" in entry for entry in rendered): | ||
| raise AssertionError(f"The system did not render the recording {presentation}") | ||
| for entry in rendered: | ||
| frame = re.search(r"\(frame \(([^)]+)\)\)", entry) | ||
| if frame is None: | ||
| raise AssertionError("The system-rendered activity has no layout frame") | ||
| values = frame[1].replace(";", " ").split() | ||
| if not all(math.isfinite(float(value)) for value in values): | ||
| raise AssertionError(f"Invalid system activity layout: {frame[0]}") | ||
| return len(rendered) | ||
|
|
||
|
|
||
| def main(): | ||
| simulator = os.environ.get("LOGSEQ_IOS_SIMULATOR", "booted") | ||
| artifacts = ROOT / "_build/recording-lockscreen-review" | ||
| artifacts.mkdir(parents=True, exist_ok=True) | ||
| render_log = artifacts / "system-render.log" | ||
| check_log = artifacts / "system-check.log" | ||
| environment = os.environ.copy() | ||
| environment.update({ | ||
| "LOGSEQ_RUNTIME_CHECK_WIDGETS": "1", | ||
| "SIMCTL_CHILD_LOGSEQ_ACTIVITY_SYSTEM_RENDER": "1", | ||
| }) | ||
| with render_log.open("w") as output: | ||
| logger = subprocess.Popen([ | ||
| "xcrun", "simctl", "spawn", simulator, "log", "stream", "--level", "debug", | ||
| "--style", "compact", "--predicate", 'process == "WidgetRenderer_Activities"', | ||
| ], stdout=output, stderr=subprocess.STDOUT) | ||
| try: | ||
| result = subprocess.run([ | ||
| sys.executable, str(ROOT / "apple/Tests/UI/run-simulator-runtime-check.py"), | ||
| str(ROOT / "apple/Tests/UI/recording-live-activity.swift"), "CheckRecordingLiveActivity", | ||
| ], env=environment, capture_output=True, text=True, timeout=90) | ||
| check_log.write_text(result.stdout + result.stderr) | ||
| if result.returncode: | ||
| raise SystemExit(f"Live Activity runtime check failed; see {check_log}") | ||
| finally: | ||
| logger.send_signal(signal.SIGINT) | ||
| try: | ||
| logger.wait(timeout=5) | ||
| except subprocess.TimeoutExpired: | ||
| logger.kill() | ||
| logger.wait() | ||
| activity = re.search(r"SYSTEM_ACTIVITY_ID=([^\s]+)", check_log.read_text()) | ||
| if activity is None: | ||
| raise SystemExit(f"The runtime check did not return an activity ID; see {check_log}") | ||
| try: | ||
| count = validate_render(render_log.read_text(), activity[1]) | ||
| except AssertionError as error: | ||
| raise SystemExit(f"{error}; see {render_log}") from None | ||
| print(f"PASS: {count} system-rendered recording views have finite layout frames, including the lock-screen card and compact timer") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
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.
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.
🔍 Timer visibility remains untested
validate_renderrejects nonfinite frames but accepts zero-sized ones. The check can pass even when the timer occupies no visible space.Was this helpful? React with 👍 or 👎 to provide feedback.