From 7c24fb628928ded53acb1fea75c24cff24393be2 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:30:00 +0200 Subject: [PATCH 01/10] Send the device's wall clock with every live stream frame Each frame header now carries realtimeUs, the device's wall clock at capture, which is the clock logcat stamps messages with. The frame header grows from 32 to 40 bytes, so the protocol version goes to 3. Co-Authored-By: Claude Opus 5.5 --- External/UnityLogcatServer/README.md | 3 ++- External/UnityLogcatServer/gradle.properties | 2 +- .../main/java/com/unity/android/logcat/server/Protocol.java | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/External/UnityLogcatServer/README.md b/External/UnityLogcatServer/README.md index b24c105e..713389f4 100644 --- a/External/UnityLogcatServer/README.md +++ b/External/UnityLogcatServer/README.md @@ -194,8 +194,9 @@ Stream header, once, 20 bytes: u32 flags bit 0: the server can inject input u32 serverPid this process on the device, so the Editor can name it -Frame, repeated, 28 byte header + payload: +Frame, repeated, 40 byte header + payload: u64 ptsUs microseconds since the first frame + u64 realtimeUs wall clock at capture, microseconds since the epoch u32 width pixels of the streamed image u32 height pixels of the streamed image u32 displayWidth pixels of the display it was captured from diff --git a/External/UnityLogcatServer/gradle.properties b/External/UnityLogcatServer/gradle.properties index 2dd5aa14..87bca995 100644 --- a/External/UnityLogcatServer/gradle.properties +++ b/External/UnityLogcatServer/gradle.properties @@ -1,7 +1,7 @@ # Version of the wire protocol spoken between the Editor and the on-device server. # The Editor refuses to talk to a server whose protocol version it does not know, # so bump this whenever the packet layout in Protocol.java changes. -serverProtocolVersion=2 +serverProtocolVersion=3 # Android platform the server is compiled against (android.jar is taken from # $SDK/platforms/android-/android.jar). diff --git a/External/UnityLogcatServer/src/main/java/com/unity/android/logcat/server/Protocol.java b/External/UnityLogcatServer/src/main/java/com/unity/android/logcat/server/Protocol.java index 39b0e12c..567c85db 100644 --- a/External/UnityLogcatServer/src/main/java/com/unity/android/logcat/server/Protocol.java +++ b/External/UnityLogcatServer/src/main/java/com/unity/android/logcat/server/Protocol.java @@ -17,8 +17,9 @@ * u32 flags FLAG_CONTROL_SUPPORTED if touch can be injected * u32 serverPid this process on the device, so the Editor can name it * - * Frame, repeated, 32 byte header + payload: + * Frame, repeated, 40 byte header + payload: * u64 ptsUs microseconds since the first frame + * u64 realtimeUs wall clock at capture, microseconds since the epoch * u32 width pixels of the streamed image * u32 height pixels of the streamed image * u32 displayWidth pixels of the display it was captured from @@ -70,6 +71,9 @@ public void writeFrame(long captureNs, int width, int height, int displayWidth, firstFrameNs = captureNs; } out.writeLong((captureNs - firstFrameNs) / 1000L); + // The clock logcat stamps messages with, so the Editor can place them among + // the frames. Taken back by the frame's age, as it was captured a moment ago. + out.writeLong(System.currentTimeMillis() * 1000L - (System.nanoTime() - captureNs) / 1000L); out.writeInt(width); out.writeInt(height); out.writeInt(displayWidth); From 61164696bd5ce01809374a697316c714590a6bd5 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:30:00 +0200 Subject: [PATCH 02/10] Record logcat messages with a recording and list them per frame Start Recording gets a dropdown with Include Logcat Messages, off by default. When enabled, the recording runs its own logcat, filtered as the Android Logcat window is when recording starts, with '-v epoch -v usec' so messages can be placed among the frames using the frame's device wall clock. Each message is saved in the recording's .json, on the frame it was logged before, reusing LogcatEntry, now serializable. When the recording plays, a resizable panel under the video lists the messages with the video time of their frame, highlights the shown frame's, dims later ones, follows the video, and goes to a message's frame on click. Co-Authored-By: Claude Opus 5.5 --- com.unity.mobile.android-logcat/CHANGELOG.md | 1 + .../Documentation~/screen-capture-video.md | 11 + .../screen-capture-window-reference.md | 4 +- .../Editor/AndroidLogcat.cs | 78 ++++-- .../Editor/AndroidLogcatCaptureList.cs | 23 +- .../Editor/AndroidLogcatCaptureVideo.cs | 35 ++- .../Editor/AndroidLogcatEntry.cs | 27 +- .../Editor/AndroidLogcatLiveStream.cs | 68 ++++-- .../Editor/AndroidLogcatRecordingLogView.cs | 230 ++++++++++++++++++ .../AndroidLogcatRecordingLogView.cs.meta | 11 + .../AndroidLogcatScreenCaptureWindow.cs | 18 +- .../Editor/AndroidLogcatScreenshotInfo.cs | 3 + .../Editor/AndroidLogcatSettings.cs | 15 ++ .../Editor/AndroidLogcatStreamRecorder.cs | 57 ++++- .../Tests/Editor/AndroidLogcatGeneralTests.cs | 3 + .../AndroidLogcatStreamRecorderTests.cs | 51 +++- 16 files changed, 595 insertions(+), 40 deletions(-) create mode 100644 com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs create mode 100644 com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs.meta diff --git a/com.unity.mobile.android-logcat/CHANGELOG.md b/com.unity.mobile.android-logcat/CHANGELOG.md index 9758b2f6..71a04093 100644 --- a/com.unity.mobile.android-logcat/CHANGELOG.md +++ b/com.unity.mobile.android-logcat/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - The screenshot and the live view can be zoomed with Ctrl+Wheel (Cmd+Wheel on macOS), and the zoomed image moved with a Ctrl+middle mouse button drag or with the scrollbars that appear. - The device screen can be viewed live from the Screen Capture window: select the "Live" row at the top of the screenshot list. Clicks, drags, the scroll wheel and typing are sent to the device as touch, scroll and key events, and Ctrl+A, Ctrl+C and Ctrl+V (Cmd on macOS) select all, copy and paste on the device using its own clipboard, and Back / Home / Overview buttons sit beside the image with the stream details. - Screen recordings are now made from the live view, with **Start Recording** in the live view, instead of with `adb screenrecord`. They are saved as constant frame rate MP4 files beside the screenshots, at the live stream's **Max Frame Rate** (up to 60 fps), and follow the live view's rotation. A recording stops on its own after the **Time Limit** set in Preferences (10 minutes by default, up to 60). Recording is not available on Linux. + - A recording can save the logcat messages logged while it runs: select the arrow next to **Start Recording** and enable **Include Logcat Messages**. Messages are filtered as the Android Logcat window is when recording starts, and when the recording plays, a panel under the video lists them, highlighting those logged since the previous frame. - Recordings can be played in the Screen Capture window, with play/pause, a time slider and buttons that step one frame back or forward. - Tools->Open Terminal is now supported on Linux Editor. - Fixed Tools->Open Terminal not opening a window on Windows Editor when running on CoreCLR. diff --git a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md index 97d10fd7..ef694be8 100644 --- a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md +++ b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md @@ -17,6 +17,17 @@ To change the size, quality, and frame rate of a recording, use **Max Size**, ** The device sends a frame only when its screen changes. While the screen is still, the recording repeats the last frame. A recording stops automatically after the **Time Limit** in the [Recording settings](android-logcat-settings.md#recording), which is 10 minutes by default. A recording also stops and is saved when Unity reloads scripts, for example after you change a script. +## Record logcat messages + +A recording can also save the logcat messages the device logs while you record, so that you can see what the device logged at each frame when you play the recording back. + +1. Select the arrow next to **Start Recording** in the [Live view details](screen-capture-window-reference.md#live-view-details). +2. Select **Include Logcat Messages**. This option is disabled by default, and applies from the next recording you start. + +The recording saves the messages the [Android Logcat window](android-logcat-window.md) would display: the selected package, priority, tags, and filter text when recording starts. The messages are saved in the `.json` file next to the recording. + +When you play the recording in the [Capture preview](screen-capture-window-reference.md#capture-preview), the messages appear in a panel under the video. Each message belongs to the first frame captured after it was logged, and starts with that frame's time in the video, as the player displays it, followed by the time on the device. The messages of the current frame, logged since the previous frame, are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. Drag the divider above the panel to resize it. + ## Recording limitations * When recording a video, the Screen Recorder Tool doesn't capture sound. diff --git a/com.unity.mobile.android-logcat/Documentation~/screen-capture-window-reference.md b/com.unity.mobile.android-logcat/Documentation~/screen-capture-window-reference.md index 898e19d2..df7c23e1 100644 --- a/com.unity.mobile.android-logcat/Documentation~/screen-capture-window-reference.md +++ b/com.unity.mobile.android-logcat/Documentation~/screen-capture-window-reference.md @@ -96,6 +96,8 @@ This section appears beside the image while a screenshot or a recording is selec When you select a recording, it opens on its first frame and is paused. The recording loops during playback. Use the play button to play and pause the recording. While the recording is paused, use the step buttons to go back or forward one frame. To move to another point in the recording, whether it is playing or paused, drag the slider. A playing recording pauses while you drag the slider, and resumes from the new point when you release it. Next to the step buttons is the current time and the length of the recording, in seconds and hundredths of a second. For a recording of one minute or longer, the time also includes minutes. +If a recording was made with **Include Logcat Messages**, a panel under the video lists the messages logged during the recording. The messages logged since the previous frame are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. For more information, refer to [Record logcat messages](screen-capture-video.md#record-logcat-messages). + ## Live view details This section appears beside the image while **Live** is selected. @@ -143,7 +145,7 @@ The device navigation buttons work while the live view is streaming and the devi | **Half** | Holds the device half open, regardless of the hinge position. Appears only for devices that report half open as a separate state. | | **Unfold** | Holds the device unfolded, regardless of the hinge position. | -Under **Device Capture**, **Take Screenshot** captures the device screen and adds it to the [Capture list](#capture-list). **Ctrl+Shift+S** (macOS: **Cmd+Shift+S**) does the same while this window has focus and **Live** is selected. The shortcut has no effect while a saved capture is selected. **Start Recording** records the live view and changes to **Stop Recording**, and the view shows how long it has been recording. The recording is added to the list when it stops. The [Capture list](#capture-list) is disabled while recording. Closing the window, or the live stream stopping, also stops the recording, so a recording never continues out of sight. Screenshots are taken on the device, so they are full resolution regardless of how the stream is scaled. Recordings are made from the stream, so they are the stream's size. +Under **Device Capture**, **Take Screenshot** captures the device screen and adds it to the [Capture list](#capture-list). **Ctrl+Shift+S** (macOS: **Cmd+Shift+S**) does the same while this window has focus and **Live** is selected. The shortcut has no effect while a saved capture is selected. **Start Recording** records the live view and changes to **Stop Recording**, and the view shows how long it has been recording. The arrow next to **Start Recording** opens a menu with **Include Logcat Messages**, which saves logcat messages with the next recording. For more information, refer to [Record logcat messages](screen-capture-video.md#record-logcat-messages). The recording is added to the list when it stops. The [Capture list](#capture-list) is disabled while recording. Closing the window, or the live stream stopping, also stops the recording, so a recording never continues out of sight. Screenshots are taken on the device, so they are full resolution regardless of how the stream is scaled. Recordings are made from the stream, so they are the stream's size. For how to interact with the device and how to change the size, quality, and frame rate of the stream, refer to [View the device screen live](screen-capture-live-stream.md). diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs index 25cfb9fe..f0a1a204 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs @@ -18,6 +18,9 @@ internal class AndroidLogcat private readonly int m_ProcessId; private readonly Priority m_MessagePriority; private readonly string[] m_Tags; + // Reading for a recording: messages from now on, stamped with the device's wall + // clock so they can be placed among the frames. + private readonly bool m_ForRecording; private readonly LogcatFilterOptions m_FilterOptions; private FilterOptions m_LastUsedFilterOptions; private List m_RawLogEntries = new List(); @@ -122,7 +125,8 @@ public AndroidLogcat(AndroidLogcatRuntimeBase runtime, int processId, Priority priority, FilterOptions filterOptions, - string[] tags) + string[] tags, + bool forRecording = false) { this.m_Runtime = runtime; this.adb = adb; @@ -132,10 +136,13 @@ public AndroidLogcat(AndroidLogcatRuntimeBase runtime, this.m_FilterOptions = new LogcatFilterOptions(filterOptions); this.m_LastUsedFilterOptions = new FilterOptions(m_FilterOptions); this.m_Tags = tags; + this.m_ForRecording = forRecording; m_FilterOptions.OnFilterChanged = OnFilterChanged; - LogcatEntry.SetTimeFormat(m_Device.SupportYearFormat ? LogcatEntry.kTimeFormatWithYear : LogcatEntry.kTimeFormatWithoutYear); + // Shared by every entry, and a recording's are never shown in the Logcat window. + if (!forRecording) + LogcatEntry.SetTimeFormat(m_Device.SupportYearFormat ? LogcatEntry.kTimeFormatWithYear : LogcatEntry.kTimeFormatWithoutYear); } private void ClearEntries() @@ -255,6 +262,9 @@ void ProcessCachedLogLines() var m = regex.Match(logLine); if (!m.Success) { + // A recording places messages by their time, which these have none of. + if (m_ForRecording) + continue; // The reason we need to check `needFilterByTags` is we don't really want to show the error logs that we can't parse if a tag is chosen. // For logs we can't parse, please refer to https://gitlab.cds.internal.unity3d.com/upm-packages/mobile/mobile-android-logcat/issues/44 // And we should remove this check once #44 is fixed completely. @@ -284,6 +294,13 @@ void ProcessCachedLogLines() FilterEntriesUsingRawEntries(entries); } + /// Hands on what has arrived without waiting for the next update, before stopping. + internal void Flush() + { + if (m_MessageProvider != null) + ProcessCachedLogLines(); + } + public void StripRawEntriesIfNeeded() { var rawMaxCount = m_Runtime.Settings.MaxCachedMessageCount; @@ -361,28 +378,43 @@ private LogcatEntry ParseLogEntry(Match m) { DateTime dateTime; var dateValue = m.Groups["date"].Value; + if (m_ForRecording) + dateTime = EpochToDateTime(dateValue); + else + dateTime = ParseDate(dateValue); + + var entry = new LogcatEntry( + dateTime, + Int32.Parse(m.Groups["pid"].Value), + Int32.Parse(m.Groups["tid"].Value), + PriorityStringToEnum(m.Groups["priority"].Value), + m.Groups["tag"].Value, + m.Groups["msg"].Value); + + return entry; + } + + DateTime ParseDate(string dateValue) + { if (LogPrintFormat == kThreadTime) dateValue = "1999-" + dateValue; try { - dateTime = DateTime.Parse(dateValue); + return DateTime.Parse(dateValue); } catch (Exception ex) { - dateTime = new DateTime(); AndroidLogcatInternalLog.Log("Failed to parse date: " + dateValue + "\n" + ex.Message); + return new DateTime(); } + } - var entry = new LogcatEntry( - dateTime, - Int32.Parse(m.Groups["pid"].Value), - Int32.Parse(m.Groups["tid"].Value), - PriorityStringToEnum(m.Groups["priority"].Value), - m.Groups["tag"].Value, - m.Groups["msg"].Value); - - return entry; + /// '-v epoch -v usec' seconds, in UTC: decimal keeps the microseconds a double would round. + static DateTime EpochToDateTime(string seconds) + { + var value = decimal.Parse(seconds, System.Globalization.CultureInfo.InvariantCulture); + return DateTime.SpecifyKind(DateTime.UnixEpoch.AddTicks((long)(value * TimeSpan.TicksPerSecond)), DateTimeKind.Utc); } private Priority PriorityStringToEnum(string priority) @@ -446,7 +478,12 @@ internal void DoDebuggingGUI() internal Regex LogParseRegex { - get { return m_Device.SupportYearFormat ? m_LogCatEntryYearRegex : m_LogCatEntryThreadTimeRegex; } + get + { + if (m_ForRecording) + return m_LogCatEntryEpochRegex; + return m_Device.SupportYearFormat ? m_LogCatEntryYearRegex : m_LogCatEntryThreadTimeRegex; + } } /// @@ -457,13 +494,21 @@ internal Regex LogParseRegex /// internal string LogPrintFormat { - get { return m_Device.SupportYearFormat ? kYearTime : kThreadTime; } + get + { + if (m_ForRecording) + return kEpochFromNow; + return m_Device.SupportYearFormat ? kYearTime : kThreadTime; + } } internal static readonly Regex m_CrashMessageRegex = new Regex(@"^\s*#\d{2}\s*pc\s([a-fA-F0-9]{8}).*(libunity\.so|libmain\.so)", RegexOptions.Compiled); // Regex for messages produced via 'adb logcat -s -v year *:V' internal static readonly Regex m_LogCatEntryYearRegex = new Regex(@"(?\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:\s(?.*)", RegexOptions.Compiled); + // Regex for messages produced via 'adb logcat -s -v epoch -v usec *:V' + internal static readonly Regex m_LogCatEntryEpochRegex = new Regex(@"(?\d+\.\d+)\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:\s(?.*)", RegexOptions.Compiled); + // Regex for messages produced via 'adb logcat -s -v threadtime *:V' internal static readonly Regex m_LogCatEntryThreadTimeRegex = new Regex(@"(?\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:\s(?.*)", RegexOptions.Compiled); @@ -475,5 +520,8 @@ internal string LogPrintFormat // Log PrintFormats internal const string kThreadTime = "threadtime"; internal const string kYearTime = "year"; + // Placed after '-v': seconds since the epoch to the microsecond, from the latest + // message on rather than the whole buffer. + internal const string kEpochFromNow = "epoch -v usec -T 1"; } } diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs index c3caacd8..90b37e9f 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs @@ -122,6 +122,8 @@ internal static GUIStyle SelectedRow Selection m_Restore; // The frame the restored video was on, for when it opens. -1 for none. long m_RestoreVideoFrame = -1; + // The selected recording's logcat messages, null for a screenshot. + AndroidLogcatRecordingLogView m_LogView; /// What is selected, which the window keeps across a domain reload. [Serializable] @@ -337,6 +339,14 @@ internal bool DoPreviewGUI(Rect rc) AndroidLogcatStatsColumn.DrawBox(rc); + // Full width under everything else, as log lines are long. + if (PreviewIsVideo && m_LogView != null && m_LogView.HasMessages) + { + var frameRate = m_VideoPlayer.FrameRate; + rc = m_LogView.DoGUI(rc, m_VideoPlayer.TimeOf(m_VideoPlayer.Frame), + frameRate > 0 ? 1 / frameRate : 0, SeekToTime); + } + // The same column the live view draws, so the two look alike. Taken out of // the area before the image is fitted, or the image would be drawn // underneath it, and sized to its text, or a device name is cut in half. @@ -389,6 +399,13 @@ internal bool DoPreviewGUI(Rect rc) return true; } + void SeekToTime(double time) + { + var frameRate = m_VideoPlayer.FrameRate; + if (frameRate > 0) + m_VideoPlayer.SeekTo((long)Math.Round(time * frameRate)); + } + void DoStatsGUI(Rect rc) { const float kLabelWidth = AndroidLogcatStatsColumn.kLabelWidth; @@ -662,10 +679,12 @@ internal void SyncPreview() if (string.IsNullOrEmpty(path) || !File.Exists(path)) return; + m_LogView = null; if (IsVideo(path)) { - m_PreviewDetails = new PreviewDetails(null, new FileInfo(path), - AndroidLogcatScreenshotInfo.Load(path)); + var info = AndroidLogcatScreenshotInfo.Load(path); + m_PreviewDetails = new PreviewDetails(null, new FileInfo(path), info); + m_LogView = new AndroidLogcatRecordingLogView(m_Runtime, info?.frameChanges); m_VideoPlayer.Open(path, m_RestoreVideoFrame); m_RestoreVideoFrame = -1; return; diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs index 3a4095b0..39d189fd 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs @@ -19,6 +19,8 @@ internal enum Result readonly AndroidLogcatRuntimeBase m_Runtime; AndroidLogcatStreamRecorder m_Recorder; + // Reads logcat for the recording, when it saves messages. + AndroidLogcat m_Logcat; Action m_OnStopRecording; // Not the wall clock, which a clock change would move the time limit with. readonly System.Diagnostics.Stopwatch m_Clock = new System.Diagnostics.Stopwatch(); @@ -86,7 +88,8 @@ internal void StartRecording(IAndroidLogcatDevice device, Action // The constructor reports failures through Error rather than throwing. var recorder = new AndroidLogcatStreamRecorder(path, m_Runtime.Settings.LiveStreamMaxFps, stream.Texture, stream.DisplayRotation, stream.DisplaySize, stream.QuarterTurnsFor, - m_Runtime.Settings.RecordingSquareVideo ? stream.LongestFrameSide() : 0); + m_Runtime.Settings.RecordingSquareVideo ? stream.LongestFrameSide() : 0, + stream.ShownRealtimeUs, stream.ShownArrivalTicks); // The encoder is created from the live view's frame, and failing to is // reported here rather than as a recording that never writes anything. if (!string.IsNullOrEmpty(recorder.Error)) @@ -105,6 +108,34 @@ internal void StartRecording(IAndroidLogcatDevice device, Action m_OnStopRecording = onStopRecording; m_Clock.Restart(); stream.Recorder = m_Recorder; + if (m_Runtime.Settings.RecordLogcatMessages) + StartLogcat(device, recorder); + } + + /// + /// A logcat of the recording's own, filtered the way the Android Logcat window is + /// now, so the recording keeps what that window would show. + /// + void StartLogcat(IAndroidLogcatDevice device, AndroidLogcatStreamRecorder recorder) + { + if (m_Runtime.Tools == null) + return; + var user = m_Runtime.UserSettings; + var process = user.LastSelectedProcess; + var pid = process != null && process.deviceId == device.Id ? process.processId : 0; + m_Logcat = new AndroidLogcat(m_Runtime, m_Runtime.Tools.ADB, device, pid, user.SelectedPriority, + user.FilterOptions, user.Tags.GetSelectedTags(), forRecording: true); + m_Logcat.FilteredLogEntriesAdded += recorder.NoteLogs; + m_Logcat.Start(); + } + + void StopLogcat() + { + if (m_Logcat == null) + return; + m_Logcat.Flush(); + m_Logcat.Stop(); + m_Logcat = null; } /// Returns false when nothing was recording, or nothing was recorded. @@ -121,6 +152,8 @@ internal bool StopRecording() var stream = m_Runtime.LiveStream; if (stream != null) stream.Recorder = null; + // Before the recorder, which places the messages when it stops. + StopLogcat(); var recorded = recorder.Stop(); AndroidLogcatInternalLog.Log(recorder.Stats()); diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatEntry.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatEntry.cs index c20578fb..73da13c7 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatEntry.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatEntry.cs @@ -1,10 +1,16 @@ using System; using Unity.Scripting.LifecycleManagement; +using UnityEngine; namespace Unity.Android.Logcat { + /// + /// Serializable for a recording, which saves the messages logged while it ran. A + /// recording's entries are in UTC, read with '-v epoch'. + /// [NoAutoStaticsCleanup] - class LogcatEntry + [Serializable] + class LogcatEntry : ISerializationCallbackReceiver { [Flags] enum Flags @@ -34,6 +40,15 @@ public bool Selected } } + // dateTime as saved, which JsonUtility cannot write: microseconds since the epoch. + [SerializeField] + long timeUs; + + // For JsonUtility. + LogcatEntry() + { + } + public LogcatEntry(string msg) { message = msg; @@ -63,6 +78,16 @@ public LogcatEntry(DateTime dateTime, int processId, int threadId, Priority prio public string tag; public string message; + void ISerializationCallbackReceiver.OnBeforeSerialize() + { + timeUs = (dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10; + } + + void ISerializationCallbackReceiver.OnAfterDeserialize() + { + dateTime = DateTime.SpecifyKind(DateTime.UnixEpoch.AddTicks(timeUs * 10), DateTimeKind.Utc); + } + public override string ToString() { return string.Format("{0} {1} {2} {3} {4}: {5}", dateTime.ToString(s_TimeFormat), processId, threadId, priority, tag, message); diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatLiveStream.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatLiveStream.cs index 7bda9911..8dbf75e6 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatLiveStream.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatLiveStream.cs @@ -112,11 +112,11 @@ internal static string GetServerJarPath() // gradle.properties. The server sends its version in the stream header, so a // mismatch is reported rather than misparsed. const uint kProtocolMagic = 0x554C5331; // "ULS1" - const int kProtocolVersion = 2; + const int kProtocolVersion = 3; const int kCodecMjpeg = 1; const int kStreamHeaderSize = 20; // magic + version + codec + flags + serverPid - // ptsUs + width + height + displayWidth + displayHeight + rotation + payloadSize - const int kFrameHeaderSize = 32; + // ptsUs + realtimeUs + width + height + displayWidth + displayHeight + rotation + payloadSize + const int kFrameHeaderSize = 40; // Protocol.FLAG_CONTROL_SUPPORTED: the server was able to set up input // injection, so touch messages will actually do something. @@ -161,6 +161,8 @@ internal static string GetServerJarPath() const float kNavigationSpacing = 6; const float kBuildJarButtonWidth = 180; const float kReconnectButtonWidth = 100; + // The arrow beside a capture button that has options. + const float kDropdownWidth = 16; const float kNavigationButtonWidth = 60; // A row each: both labels are too wide for the two of them to share the stats // column without being clipped. @@ -236,6 +238,7 @@ static class Styles "Where the server jar was pushed on the device."); internal static readonly GUIContent ServerPid = new GUIContent("Server PID", "Process id of the server on the device, for adb shell kill or ps."); + internal static readonly GUIContent Dropdown = new GUIContent(EditorGUIUtility.IconContent("icon dropdown").image, "Options"); internal static readonly GUIContent RebuildJar = new GUIContent("Rebuild Server", "Run 'gradlew dexJar' on External/UnityLogcatServer, which also copies the jar into the " + "package, then restart the stream so the device picks the new one up and point the " + @@ -298,12 +301,18 @@ internal readonly struct CaptureAction internal readonly Action Action; /// Asked on every repaint. Null is a button that is always enabled. internal readonly Func Enabled; + /// + /// Shows options for the action under the given rect, from an arrow on the + /// button's right. Null is a plain button. + /// + internal readonly Action Dropdown; - internal CaptureAction(Func label, Action action, Func enabled = null) + internal CaptureAction(Func label, Action action, Func enabled = null, Action dropdown = null) { Label = label; Action = action; Enabled = enabled; + Dropdown = dropdown; } } @@ -342,6 +351,12 @@ sealed class ReaderSession int m_PendingDisplayHeight; int m_PendingRotation; long m_PendingPtsUs; + long m_PendingRealtimeUs; + long m_PendingArrivalTicks; + // The shown frame's device wall clock, and when it arrived on the Stopwatch's + // clock: where a recording places logcat messages until a frame of its own arrives. + long m_ShownRealtimeUs = -1; + long m_ShownArrivalTicks; long m_ReceivedBytes; int m_ReceivedFrames; @@ -433,6 +448,12 @@ internal AndroidLogcatStreamRecorder Recorder internal string Errors => m_Errors.ToString(); internal Texture2D Texture => m_Texture; + /// The shown frame's device wall clock in microseconds since the epoch, -1 before the first. + internal long ShownRealtimeUs => m_ShownRealtimeUs; + + /// When the shown frame arrived, in ticks. + internal long ShownArrivalTicks => m_ShownArrivalTicks; + /// /// Whether the server can inject input. False means the device refused to set it /// up, in which case the view is read only and says so - better than accepting @@ -525,6 +546,7 @@ internal void StartStreaming(IAndroidLogcatDevice device, m_FoldStatesQueried = false; m_PhysicalDisplaySizes = null; m_FrameWidth = 0; + m_ShownRealtimeUs = -1; m_FrameHeight = 0; m_DisplayWidth = 0; m_DisplayHeight = 0; @@ -774,7 +796,7 @@ internal void ApplyPendingFrame() int size; int width, height; int displayWidth, displayHeight, rotation; - long ptsUs; + long ptsUs, realtimeUs, arrivalTicks; lock (m_FrameLock) { @@ -788,6 +810,8 @@ internal void ApplyPendingFrame() displayHeight = m_PendingDisplayHeight; rotation = m_PendingRotation; ptsUs = m_PendingPtsUs; + realtimeUs = m_PendingRealtimeUs; + arrivalTicks = m_PendingArrivalTicks; } if (frame != null) @@ -834,6 +858,8 @@ internal void ApplyPendingFrame() m_DisplayWidth = displayWidth; m_DisplayHeight = displayHeight; m_DisplayRotation = rotation; + m_ShownRealtimeUs = realtimeUs; + m_ShownArrivalTicks = arrivalTicks; // The first frame counts as a resize, since everything was zero // until it arrived. @@ -1071,12 +1097,14 @@ void ReadFrames(ReaderSession session) // Bytes 0..7 are the presentation timestamp, in microseconds. The // view shows frames as they arrive; only a recording uses it. var ptsUs = (long)ReadInt32BE(header, 0) << 32 | (uint)ReadInt32BE(header, 4); - var width = ReadInt32BE(header, 8); - var height = ReadInt32BE(header, 12); - var displayWidth = ReadInt32BE(header, 16); - var displayHeight = ReadInt32BE(header, 20); - var rotation = ReadInt32BE(header, 24); - var size = ReadInt32BE(header, 28); + // The device's wall clock, which logcat stamps messages with. + var realtimeUs = (long)ReadInt32BE(header, 8) << 32 | (uint)ReadInt32BE(header, 12); + var width = ReadInt32BE(header, 16); + var height = ReadInt32BE(header, 20); + var displayWidth = ReadInt32BE(header, 24); + var displayHeight = ReadInt32BE(header, 28); + var rotation = ReadInt32BE(header, 32); + var size = ReadInt32BE(header, 36); if (size <= 0 || size > kMaxFrameSize) throw new IOException($"Frame size {size} is out of range, the stream is out of sync"); @@ -1087,7 +1115,7 @@ void ReadFrames(ReaderSession session) if (session != m_Session) break; - m_Recorder?.Enqueue(payload, size, ptsUs, rotation, displayWidth, displayHeight); + m_Recorder?.Enqueue(payload, size, ptsUs, realtimeUs, rotation, displayWidth, displayHeight); lock (m_FrameLock) { @@ -1111,6 +1139,8 @@ void ReadFrames(ReaderSession session) m_PendingDisplayHeight = displayHeight; m_PendingRotation = rotation; m_PendingPtsUs = ptsUs; + m_PendingRealtimeUs = realtimeUs; + m_PendingArrivalTicks = Stopwatch.GetTimestamp(); m_ReceivedBytes += size; m_ReceivedFrames++; } @@ -1926,13 +1956,23 @@ void DoCaptureActionsGUI(Rect rc, ref float y, IReadOnlyList capt return; var enabled = capture.Action != null && (capture.Enabled == null || capture.Enabled()); + var buttonRect = new Rect(rc.x, y, ButtonRowWidth(rc), height); + var dropdownRect = Rect.zero; + if (capture.Dropdown != null) + { + dropdownRect = new Rect(buttonRect.xMax - kDropdownWidth, y, kDropdownWidth, height); + buttonRect.width -= kDropdownWidth; + } EditorGUI.BeginDisabledGroup(!enabled); - if (GUI.Button(new Rect(rc.x, y, ButtonRowWidth(rc), height), - capture.Label(), EditorStyles.miniButton)) + if (GUI.Button(buttonRect, capture.Label(), + capture.Dropdown != null ? EditorStyles.miniButtonLeft : EditorStyles.miniButton)) { capture.Action(); } EditorGUI.EndDisabledGroup(); + // Options are for the next time, so they can be set before there is a stream. + if (capture.Dropdown != null && GUI.Button(dropdownRect, Styles.Dropdown, EditorStyles.miniButtonRight)) + capture.Dropdown(new Rect(rc.x, y, ButtonRowWidth(rc), height)); y += height; } diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs new file mode 100644 index 00000000..a09751ea --- /dev/null +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Unity.Scripting.LifecycleManagement; +using UnityEditor; +using UnityEngine; + +namespace Unity.Android.Logcat +{ + /// + /// The logcat messages saved with a recording, in a panel under its video. A message + /// belongs to the first frame captured after it was logged: the shown frame's are + /// highlighted, and later ones are dimmed, as the video has not reached them yet. + /// + internal class AndroidLogcatRecordingLogView + { + [NoAutoStaticsCleanup] + static class Styles + { + internal static readonly GUIContent Title = new GUIContent("Logcat Messages", + "Logged while recording, filtered as the Android Logcat window was when recording started. " + + "Each message starts with the video time of its frame, then the device's time. " + + "Highlighted: logged since the previous frame. Click a message to go to its frame."); + internal static readonly GUIStyle Row = new GUIStyle(EditorStyles.miniLabel) { clipping = TextClipping.Clip }; + internal static readonly Color Current = new Color(0.24f, 0.48f, 0.9f, 0.35f); + } + + const float kRowHeight = 16; + const float kSplitterHeight = 5; + const float kMinHeight = 60; + const float kMinVideoHeight = 100; + const float kDefaultHeight = 160; + // The time into the video, as the player shows it, then the device's clock. + const float kVideoTimeWidth = 56; + const float kTimeWidth = 84; + const float kPriorityWidth = 14; + const float kTagWidth = 150; + const float kColumnGap = 6; + const float kScrollbarWidth = 16; + // Rows after the shown frame, which the video has not reached. + const float kFutureAlpha = 0.45f; + + readonly LogcatEntry[] m_Entries; + // The time of the frame each message belongs to, in order. + readonly double[] m_FrameTimes; + // With minutes, as the player shows a recording a minute or longer. + readonly bool m_Minutes; + readonly AndroidLogcatRuntimeBase m_Runtime; + Vector2 m_Scroll; + float m_Height = kDefaultHeight; + bool m_Dragging; + // The frame the list last scrolled for, so it follows the video without + // fighting a scroll made while paused. + double m_ScrolledFor = double.NaN; + + internal bool HasMessages => m_Entries.Length > 0; + + internal AndroidLogcatRecordingLogView(AndroidLogcatRuntimeBase runtime, AndroidLogcatScreenshotInfo.FrameChange[] changes) + { + m_Runtime = runtime; + var rows = (changes ?? Array.Empty()) + .Where(change => change?.logs != null) + .OrderBy(change => change.time) + .SelectMany(change => change.logs.Select(entry => (change.time, entry))) + .ToArray(); + m_Entries = rows.Select(row => row.entry).ToArray(); + m_FrameTimes = rows.Select(row => row.time).ToArray(); + m_Minutes = m_FrameTimes.Length > 0 && m_FrameTimes[m_FrameTimes.Length - 1] >= 60; + } + + /// + /// Takes the bottom of and draws the messages there, as of + /// the frame at . Returns what is left above for the video. + /// + /// Goes to the frame at a time, for a clicked message. + internal Rect DoGUI(Rect area, double time, double frameDuration, Action seek) + { + // Clamped for this pass only: the layout pass hands a placeholder area, which + // would shrink the height the user chose every time. + var maxHeight = Mathf.Max(kMinHeight, area.height - kMinVideoHeight - kSplitterHeight); + var height = Mathf.Clamp(m_Height, kMinHeight, maxHeight); + var splitter = new Rect(area.x, area.yMax - height - kSplitterHeight, area.width, kSplitterHeight); + DoSplitter(splitter, area.yMax, maxHeight); + height = Mathf.Clamp(m_Height, kMinHeight, maxHeight); + + var panel = new Rect(area.x, area.yMax - height, area.width, height); + var above = new Rect(area.x, area.y, area.width, Mathf.Max(0, panel.y - kSplitterHeight - area.y)); + + // Within half a frame of the shown one: frame times are rounded to the frame rate. + var tolerance = frameDuration * 0.5; + var first = FirstAtOrAfter(time - tolerance); + var end = FirstAtOrAfter(time + tolerance); + + var header = new Rect(panel.x, panel.y, panel.width, EditorGUIUtility.singleLineHeight); + GUI.Label(header, Styles.Title, EditorStyles.miniBoldLabel); + var count = new GUIContent($"{end - first} at this frame, {m_Entries.Length} in all"); + var countWidth = EditorStyles.miniLabel.CalcSize(count).x; + GUI.Label(new Rect(header.xMax - countWidth - kColumnGap, header.y, countWidth, header.height), count, EditorStyles.miniLabel); + + var list = new Rect(panel.x, header.yMax, panel.width, Mathf.Max(0, panel.yMax - header.yMax)); + FollowFrame(list, time, first, end); + DoRowsGUI(list, first, end, seek); + return above; + } + + /// + /// Drags by its own flag rather than a control ID, which shifts between events + /// when anything drawn before it asks for IDs on some events only. + /// + void DoSplitter(Rect rect, float bottom, float maxHeight) + { + EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeVertical); + var id = GUIUtility.GetControlID(FocusType.Passive); + var e = Event.current; + switch (e.rawType) + { + case EventType.MouseDown: + if (e.button == 0 && rect.Contains(e.mousePosition)) + { + m_Dragging = true; + // Keeps the mouse while it is outside the window. + GUIUtility.hotControl = id; + e.Use(); + } + break; + case EventType.MouseDrag: + if (m_Dragging) + { + // From where the mouse is, so it stays on the divider. + m_Height = Mathf.Clamp(bottom - e.mousePosition.y - kSplitterHeight * 0.5f, kMinHeight, maxHeight); + e.Use(); + } + break; + case EventType.MouseUp: + if (m_Dragging) + { + m_Dragging = false; + GUIUtility.hotControl = 0; + e.Use(); + } + break; + case EventType.Repaint: + EditorGUI.DrawRect(new Rect(rect.x, rect.center.y, rect.width, 1), new Color(0, 0, 0, 0.3f)); + break; + } + } + + /// + /// When the frame changes, scrolls the shown frame's messages into view, or the + /// last one logged before it when it has none. + /// + void FollowFrame(Rect list, double time, int first, int end) + { + if (time.Equals(m_ScrolledFor)) + return; + m_ScrolledFor = time; + var last = end - 1; + if (last < 0) + { + m_Scroll.y = 0; + return; + } + var top = Mathf.Max(0, first < end ? first : last) * kRowHeight; + var bottom = (last + 1) * kRowHeight; + if (bottom - m_Scroll.y > list.height) + m_Scroll.y = bottom - list.height; + if (top < m_Scroll.y) + m_Scroll.y = top; + } + + void DoRowsGUI(Rect list, int first, int end, Action seek) + { + var content = new Rect(0, 0, list.width - kScrollbarWidth, m_Entries.Length * kRowHeight); + m_Scroll = GUI.BeginScrollView(list, m_Scroll, content, false, true); + var from = Mathf.Max(0, Mathf.FloorToInt(m_Scroll.y / kRowHeight)); + var to = Mathf.Min(m_Entries.Length, Mathf.CeilToInt((m_Scroll.y + list.height) / kRowHeight) + 1); + var e = Event.current; + var color = GUI.color; + for (var i = from; i < to; i++) + { + var row = new Rect(0, i * kRowHeight, content.width, kRowHeight); + if (e.type == EventType.MouseDown && e.button == 0 && row.Contains(e.mousePosition)) + { + seek(m_FrameTimes[i]); + e.Use(); + } + if (e.type != EventType.Repaint) + continue; + if (i >= first && i < end) + EditorGUI.DrawRect(row, Styles.Current); + GUI.color = i >= end ? new Color(color.r, color.g, color.b, color.a * kFutureAlpha) : color; + DoRowGUI(row, m_Entries[i], m_FrameTimes[i]); + } + GUI.color = color; + GUI.EndScrollView(); + } + + void DoRowGUI(Rect row, LogcatEntry entry, double frameTime) + { + var style = Styles.Row; + style.normal.textColor = m_Runtime.Settings.GetMessageColor(entry.priority); + var x = row.x + kColumnGap; + GUI.Label(new Rect(x, row.y, kVideoTimeWidth, row.height), + AndroidLogcatVideoPlayer.FormatTime(frameTime, m_Minutes), style); + x += kVideoTimeWidth; + GUI.Label(new Rect(x, row.y, kTimeWidth, row.height), entry.dateTime.ToLocalTime().ToString("HH:mm:ss.fff"), style); + x += kTimeWidth; + GUI.Label(new Rect(x, row.y, kPriorityWidth, row.height), entry.priority.ToString().Substring(0, 1), style); + x += kPriorityWidth + kColumnGap; + GUI.Label(new Rect(x, row.y, kTagWidth, row.height), entry.tag, style); + x += kTagWidth + kColumnGap; + GUI.Label(new Rect(x, row.y, Mathf.Max(0, row.xMax - x), row.height), new GUIContent(entry.message, entry.message), style); + } + + /// The first message belonging to a frame at or after . + int FirstAtOrAfter(double time) + { + int low = 0, high = m_FrameTimes.Length; + while (low < high) + { + var middle = low + (high - low) / 2; + if (m_FrameTimes[middle] < time) + low = middle + 1; + else + high = middle; + } + return low; + } + } +} diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs.meta b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs.meta new file mode 100644 index 00000000..b031eb68 --- /dev/null +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ee5a60d756f4ce9b3f7a66be1dc7dc7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenCaptureWindow.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenCaptureWindow.cs index 91aa2dfa..74b26314 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenCaptureWindow.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenCaptureWindow.cs @@ -23,11 +23,12 @@ class Styles + "Shortcut: Ctrl+Shift+S, Cmd+Shift+S on macOS, while this view is showing."); public static readonly GUIContent StartRecording = new GUIContent("Start Recording", "Record the live view, at the stream's size, and add the recording to the list when " - + "it stops. Leaving the live view stops it."); + + "it stops. Leaving the live view stops it. The arrow beside it chooses what else is saved with the recording."); public static readonly GUIContent StopRecording = new GUIContent("Stop Recording", "Stop recording and add the recording to the list."); public static readonly GUIContent RecordingUnsupported = new GUIContent("Start Recording", "Recording isn't available on Linux, the Linux Editor has no H.264 encoder."); + public static readonly GUIContent IncludeLogcatMessages = new GUIContent("Include Logcat Messages"); } private AndroidLogcatRuntimeBase m_Runtime; @@ -97,7 +98,7 @@ private void OnEnable() // not, and two buttons would leave one of them dead most of the time. new AndroidLogcatLiveStream.CaptureAction( () => m_CaptureVideo.IsRecording ? Styles.StopRecording : RecordingSupported ? Styles.StartRecording : Styles.RecordingUnsupported, - ToggleRecording, () => CanRecord) + ToggleRecording, () => CanRecord, ShowRecordingOptions) }; m_Runtime.DeviceQuery.UpdateConnectedDevicesList(true); @@ -186,6 +187,19 @@ private void ToggleRecording() } } + /// What a recording saves besides the video. Applies to the next one. + private void ShowRecordingOptions(Rect rect) + { + var settings = m_Runtime.Settings; + var menu = new GenericMenu(); + if (m_CaptureVideo.IsRecording) + menu.AddDisabledItem(Styles.IncludeLogcatMessages, settings.RecordLogcatMessages); + else + menu.AddItem(Styles.IncludeLogcatMessages, settings.RecordLogcatMessages, + () => settings.RecordLogcatMessages = !settings.RecordLogcatMessages); + menu.DropDown(rect); + } + private void QueueScreenCapture() { // Whatever the bar said about the last one is about to be out of date. diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs index f2aca159..11d1e5ca 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs @@ -45,6 +45,9 @@ internal class FrameChange public DisplayInfo display = new DisplayInfo(); public ContentInfo content = new ContentInfo(); public List touches = new List(); + // Logged since the frame before this one, up to this one, filtered as the + // Android Logcat window was when recording started. + public List logs = new List(); } /// diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatSettings.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatSettings.cs index 22ef8c5c..50d4615b 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatSettings.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatSettings.cs @@ -96,6 +96,9 @@ internal class AndroidLogcatSettings [SerializeField] private bool m_RecordTouches; + [SerializeField] + private bool m_RecordLogcatMessages; + internal int MemoryRequestIntervalMS { set @@ -267,6 +270,17 @@ internal bool RecordTouches get => m_RecordTouches; } + /// + /// Whether a recording also saves the logcat messages the Android Logcat window + /// would show, for its player to list frame by frame. Off by default: a busy + /// device can log a lot. + /// + internal bool RecordLogcatMessages + { + set => Set(ref m_RecordLogcatMessages, value); + get => m_RecordLogcatMessages; + } + /// /// Frame rate cap of the live stream. A mirrored display only produces a frame /// when the screen changes, so this is a ceiling rather than a rate. @@ -371,6 +385,7 @@ internal void Reset() m_RecordingTimeLimit = kRecordingTimeLimit.Default; m_RecordingSquareVideo = true; m_RecordTouches = true; + m_RecordLogcatMessages = false; ResetLiveStreamFields(); if (Enum.GetValues(typeof(Priority)).Length != 6) throw new Exception("Unexpected length of Priority enum."); diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs index 4e449c17..53864158 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs @@ -44,6 +44,7 @@ struct QueuedFrame { internal byte[] Data; internal long PtsUs; + internal long RealtimeUs; internal long ArrivalUs; internal int Rotation; internal int DisplayWidth; @@ -91,6 +92,13 @@ struct QueuedFrame long m_FirstPtsUs = -1; // Where the first device frame lands on the recording's clock. long m_FirstArrivalUs; + // Logcat messages, placed among the frames on Stop: a frame has to arrive before + // the device's clock can be read against the recording's. + readonly List m_Logs = new List(); + // A device wall clock time and where it falls on the recording's clock: the first + // frame's, or until one arrives, the live view's last. + long m_AnchorRealtimeUs = -1; + long m_AnchorUs; // Stats, logged when a recording stops. int m_Received; @@ -120,10 +128,21 @@ struct QueuedFrame /// The video is a square of this, so any frame fits it turned either way. 0 sizes /// it to the first frame instead. /// + /// + /// The device wall clock of , -1 when unknown, and + /// when it arrived, in Stopwatch ticks. + /// internal AndroidLogcatStreamRecorder(string path, int frameRate, Texture2D current, int currentRotation, - Vector2Int currentDisplaySize, Func quarterTurnsFor, int side = 0) + Vector2Int currentDisplaySize, Func quarterTurnsFor, int side = 0, + long currentRealtimeUs = -1, long currentArrivalTicks = 0) { m_Path = path; + if (currentRealtimeUs >= 0) + { + m_AnchorRealtimeUs = currentRealtimeUs; + var startTicks = Stopwatch.GetTimestamp() - m_Clock.ElapsedTicks; + m_AnchorUs = (currentArrivalTicks - startTicks) * 1000000 / Stopwatch.Frequency; + } m_Side = side; m_FrameRate = Math.Max(1, frameRate); // After the frame rate, which turns its slot into a time. @@ -156,7 +175,7 @@ internal AndroidLogcatStreamRecorder(string path, int frameRate, Texture2D curre long SlotAt(long us) => (long)Math.Round(us * (double)m_FrameRate / 1000000); /// Reader thread. Copies the frame, since the reader reuses its buffers. - internal void Enqueue(byte[] data, int size, long ptsUs, int rotation, int displayWidth, int displayHeight) + internal void Enqueue(byte[] data, int size, long ptsUs, long realtimeUs, int rotation, int displayWidth, int displayHeight) { lock (m_Lock) { @@ -175,6 +194,7 @@ internal void Enqueue(byte[] data, int size, long ptsUs, int rotation, int displ { Data = copy, PtsUs = ptsUs, + RealtimeUs = realtimeUs, ArrivalUs = NowUs, Rotation = rotation, DisplayWidth = displayWidth, @@ -297,6 +317,12 @@ void Decode(QueuedFrame frame) { m_FirstPtsUs = frame.PtsUs; m_FirstArrivalUs = frame.ArrivalUs; + // The same anchor as the frames, so a message lands where they do. + if (frame.RealtimeUs > 0) + { + m_AnchorRealtimeUs = frame.RealtimeUs; + m_AnchorUs = frame.ArrivalUs; + } } var slot = SlotAt(m_FirstArrivalUs + frame.PtsUs - m_FirstPtsUs); @@ -346,6 +372,32 @@ void NoteDisplaySize(int width, int height, long slot) /// 0 to 1 from the top left. Android does not draw injected touches, so a player /// draws these instead. Only the last move of a frame is kept. /// + /// Logcat messages, as the Android Logcat window filters them. + internal void NoteLogs(IEnumerable entries) + { + m_Logs.AddRange(entries); + } + + /// + /// Each message goes to the frame whose slot it was logged in, so a frame lists + /// what was logged since the one before it. + /// + void PlaceLogs(long lastSlot) + { + if (m_AnchorRealtimeUs < 0 || lastSlot < 0) + return; + foreach (var entry in m_Logs) + { + var realtimeUs = (entry.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10; + var slot = SlotAt(m_AnchorUs + realtimeUs - m_AnchorRealtimeUs); + // Logged before the recording started. + if (slot < 0) + continue; + ChangeAt((double)Math.Min(slot, lastSlot) / m_FrameRate).logs.Add(entry); + } + m_Logs.Clear(); + } + internal void NoteTouch(AndroidLogcatLiveStream.TouchAction action, float x, float y) { var change = ChangeAt((double)SlotAt(NowUs) / m_FrameRate); @@ -510,6 +562,7 @@ internal bool Stop() } finally { + PlaceLogs(m_Written - 1); try { m_Encoder?.Dispose(); diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs index 9b4ae71e..a6bf4ea5 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs @@ -303,6 +303,8 @@ public void LiveStreamSettingsTests() settings.RecordingSquareVideo = false; Assert.IsTrue(settings.RecordTouches, "Recording touches should be on by default"); settings.RecordTouches = false; + Assert.IsFalse(settings.RecordLogcatMessages, "Recording logcat messages should be off by default"); + settings.RecordLogcatMessages = true; // And the whole page Reset takes them with everything else. settings.LiveStreamMaxSize = 512; @@ -310,6 +312,7 @@ public void LiveStreamSettingsTests() Assert.AreEqual(AndroidLogcatSettings.kRecordingTimeLimit.Default, settings.RecordingTimeLimit); Assert.IsTrue(settings.RecordingSquareVideo, "Reset should turn square video back on"); Assert.IsTrue(settings.RecordTouches, "Reset should turn recording touches back on"); + Assert.IsFalse(settings.RecordLogcatMessages, "Reset should turn recording logcat messages back off"); Assert.AreEqual(AndroidLogcatSettings.kLiveStreamMaxSize.Default, settings.LiveStreamMaxSize); Assert.AreEqual(AndroidLogcatSettings.kLiveStreamQuality.Default, settings.LiveStreamQuality); Assert.AreEqual(AndroidLogcatSettings.kLiveStreamMaxFps.Default, settings.LiveStreamMaxFps); diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs index 04fd91d1..d60e8662 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs @@ -51,8 +51,8 @@ public void ChangesOfAQueuedFrameKeepTheirTimeAfterALaterTouch() var portrait = Jpeg(64, 128); m_Recorder = new AndroidLogcatStreamRecorder(Path.Combine(m_Folder, "touch.mp4"), kFrameRate, null, 0, Vector2Int.zero, rotation => 0); - m_Recorder.Enqueue(landscape, landscape.Length, 0, 0, 2424, 1080); - m_Recorder.Enqueue(portrait, portrait.Length, kFrameUs, 0, 1080, 2424); + m_Recorder.Enqueue(landscape, landscape.Length, 0, 0, 0, 2424, 1080); + m_Recorder.Enqueue(portrait, portrait.Length, kFrameUs, 0, 0, 1080, 2424); // Well past both frames' slots, on the recording's clock. Thread.Sleep(300); @@ -77,6 +77,53 @@ public void ChangesOfAQueuedFrameKeepTheirTimeAfterALaterTouch() Assert.IsFalse(touch.display.IsSet, "The frame's display change was merged into the touch"); } + [Test] + public void LogsLandOnTheFrameTheyWereLoggedBeforeAndSurviveSaving() + { + // The device's wall clock when the only frame was captured. + const long kFrameRealtimeUs = 1794578375000000; + var frame = Jpeg(64, 128); + m_Recorder = new AndroidLogcatStreamRecorder(Path.Combine(m_Folder, "logs.mp4"), kFrameRate, + null, 0, Vector2Int.zero, rotation => 0); + m_Recorder.Enqueue(frame, frame.Length, 0, kFrameRealtimeUs, 0, 1080, 2424); + m_Recorder.NoteLogs(new[] + { + Log(kFrameRealtimeUs - 1000000, "before the recording"), + Log(kFrameRealtimeUs + 2 * kFrameUs, "two frames in"), + Log(kFrameRealtimeUs + 60 * 1000000L, "after it stopped") + }); + + // Long enough for several frames, so the messages have somewhere to go. + Thread.Sleep(300); + var recorder = m_Recorder; + m_Recorder = null; + Assert.IsTrue(recorder.Stop(), $"Nothing was recorded. {recorder.Error}"); + + var logged = recorder.FrameChanges.Where(change => change.logs.Count > 0).ToArray(); + Assert.IsFalse(logged.SelectMany(change => change.logs).Any(entry => entry.message == "before the recording"), + "A message logged before the recording started should be left out"); + var twoIn = logged.Single(change => change.logs.Any(entry => entry.message == "two frames in")); + // Two frames after the only one, give or take how long queueing took. + Assert.That(twoIn.time, Is.InRange(1.0 / kFrameRate, 4.0 / kFrameRate)); + var last = recorder.FrameChanges.Max(change => change.time); + var after = logged.Single(change => change.logs.Any(entry => entry.message == "after it stopped")); + Assert.AreEqual(last, after.time, "A message after the last frame should land on the last frame"); + + var info = new AndroidLogcatScreenshotInfo { frameChanges = recorder.FrameChanges.ToArray() }; + var loaded = JsonUtility.FromJson(JsonUtility.ToJson(info)); + var saved = loaded.frameChanges.SelectMany(change => change.logs).Single(entry => entry.message == "two frames in"); + Assert.AreEqual(kFrameRealtimeUs + 2 * kFrameUs, (saved.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10); + Assert.AreEqual(Priority.Warn, saved.priority); + Assert.AreEqual("Tag", saved.tag); + Assert.AreEqual(12, saved.processId); + } + + static LogcatEntry Log(long realtimeUs, string message) + { + var time = DateTime.SpecifyKind(DateTime.UnixEpoch.AddTicks(realtimeUs * 10), DateTimeKind.Utc); + return new LogcatEntry(time, 12, 34, Priority.Warn, "Tag", message); + } + static byte[] Jpeg(int width, int height) { var texture = new Texture2D(width, height, TextureFormat.RGB24, false); From 5ea2f639cfa2e4b5c029fd2cd1301ee2413b4ee5 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:30:00 +0200 Subject: [PATCH 03/10] Show and log typed characters in the sample project DebugMethods displays what is typed on screen and logs each change, for testing keyboard input and logcat recording from the live view. Co-Authored-By: Claude Opus 5.5 --- .../SampleProject1/Assets/DebugMethods.cs | 61 +++++++++++++++++-- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/TestProjects/SampleProject1/Assets/DebugMethods.cs b/TestProjects/SampleProject1/Assets/DebugMethods.cs index 81916a00..82beedc5 100644 --- a/TestProjects/SampleProject1/Assets/DebugMethods.cs +++ b/TestProjects/SampleProject1/Assets/DebugMethods.cs @@ -4,21 +4,72 @@ public class DebugMethods : MonoBehaviour { + const int kMaxTypedLength = 200; + + // What was typed, as Input.inputString reports it: backspace removes the last + // character and Enter starts a new line. + string m_Typed = string.Empty; + GUIStyle m_TypedStyle; + // Start is called before the first frame update void Start() { - StartCoroutine("runner"); + TestDebug(); } - IEnumerator runner() + void Update() { - while (true) + var input = Input.inputString; + if (string.IsNullOrEmpty(input)) + return; + + foreach (var c in input) { - TestDebug(); - yield return new WaitForSeconds(2); + if (c == '\b') + { + if (m_Typed.Length > 0) + m_Typed = m_Typed.Substring(0, m_Typed.Length - 1); + } + else if (c == '\n' || c == '\r') + { + m_Typed += '\n'; + } + else + { + m_Typed += c; + } } + + if (m_Typed.Length > kMaxTypedLength) + m_Typed = m_Typed.Substring(m_Typed.Length - kMaxTypedLength); + + // Logged too, so typing shows up in logcat. + Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Typed: '{0}'", Escape(input)); } + void OnGUI() + { + if (m_TypedStyle == null) + { + m_TypedStyle = new GUIStyle(GUI.skin.label) + { + fontSize = Mathf.Max(24, Screen.height / 30), + wordWrap = true + }; + m_TypedStyle.normal.textColor = Color.white; + } + + var margin = Screen.width * 0.05f; + var rect = new Rect(margin, margin, Screen.width - 2 * margin, Screen.height - 2 * margin); + GUI.Label(rect, "Typed: " + m_Typed + "_", m_TypedStyle); + } + + static string Escape(string input) + { + return input.Replace("\b", "\\b").Replace("\n", "\\n").Replace("\r", "\\r"); + } + + public void TestDebug() { Debug.Log("This is a simple LOG message"); From d5c341c754e9f85f7e29bf1e1c73e11155ed2a4a Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:32:48 +0200 Subject: [PATCH 04/10] Rename AndroidLogcatScreenshotInfo to AndroidLogcatCaptureInfo The details file describes recordings too, with what changed while they ran, so the name says capture rather than screenshot. JsonUtility doesn't store the class name, so existing .json files load as before. Co-Authored-By: Claude Opus 5.5 --- ...hotInfo.cs => AndroidLogcatCaptureInfo.cs} | 23 +++++++------- ....meta => AndroidLogcatCaptureInfo.cs.meta} | 0 .../Editor/AndroidLogcatCaptureList.cs | 22 +++++++------- .../Editor/AndroidLogcatCaptureScreenshot.cs | 14 ++++----- .../Editor/AndroidLogcatCaptureVideo.cs | 10 +++---- .../Editor/AndroidLogcatRecordingLogView.cs | 4 +-- .../Editor/AndroidLogcatStreamRecorder.cs | 12 ++++---- .../Editor/AndroidLogcatUtilities.cs | 4 +-- .../Tests/Editor/AndroidLogcatGeneralTests.cs | 30 +++++++++---------- .../AndroidLogcatRecordingLookupTests.cs | 18 +++++------ .../AndroidLogcatStreamRecorderTests.cs | 4 +-- .../AndroidLogcatIntegrationScreenCapture.cs | 10 +++---- 12 files changed, 76 insertions(+), 75 deletions(-) rename com.unity.mobile.android-logcat/Editor/{AndroidLogcatScreenshotInfo.cs => AndroidLogcatCaptureInfo.cs} (91%) rename com.unity.mobile.android-logcat/Editor/{AndroidLogcatScreenshotInfo.cs.meta => AndroidLogcatCaptureInfo.cs.meta} (100%) diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureInfo.cs similarity index 91% rename from com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs rename to com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureInfo.cs index 11d1e5ca..7a78226f 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureInfo.cs @@ -6,13 +6,14 @@ namespace Unity.Android.Logcat { /// - /// What a screenshot cannot say about itself: the device it came from, and when. - /// Written beside the image as <name>.json when it is captured, and - /// moved and deleted with it. A screenshot that has none - captured before this - /// existed, or dropped into the folder by hand - shows Undefined instead. + /// What a capture - a screenshot or a recording - cannot say about itself: the device + /// it came from, and when, and for a recording what changed while it ran. Written + /// beside the capture as <name>.json, and moved and deleted with it. A + /// capture that has none - taken before this existed, or dropped into the folder by + /// hand - shows Undefined instead. /// [Serializable] - internal class AndroidLogcatScreenshotInfo + internal class AndroidLogcatCaptureInfo { internal const string kExtension = ".json"; @@ -98,7 +99,7 @@ internal static string PathFor(string imagePath) /// Reads the device. Talks to adb for the display size, so this belongs on the /// thread the capture itself runs on, not on the GUI's. /// - internal static AndroidLogcatScreenshotInfo Create(IAndroidLogcatDevice device) + internal static AndroidLogcatCaptureInfo Create(IAndroidLogcatDevice device) { if (device == null) return null; @@ -117,7 +118,7 @@ internal static AndroidLogcatScreenshotInfo Create(IAndroidLogcatDevice device) var manufacturer = device.Manufacturer ?? string.Empty; var model = device.Model ?? string.Empty; - return new AndroidLogcatScreenshotInfo() + return new AndroidLogcatCaptureInfo() { capturedAt = DateTime.Now.ToString("o"), deviceId = device.Id, @@ -132,7 +133,7 @@ internal static AndroidLogcatScreenshotInfo Create(IAndroidLogcatDevice device) }; } - static bool IsDetails(AndroidLogcatScreenshotInfo info) + static bool IsDetails(AndroidLogcatCaptureInfo info) { return info != null && info.version > 0 && !string.IsNullOrEmpty(info.capturedAt); } @@ -144,7 +145,7 @@ static bool IsFree(string path) try { - return IsDetails(JsonUtility.FromJson(File.ReadAllText(path))); + return IsDetails(JsonUtility.FromJson(File.ReadAllText(path))); } catch (Exception) { @@ -193,7 +194,7 @@ internal void Save(string imagePath) } /// Returns null when there is no file, or it cannot be read. - internal static AndroidLogcatScreenshotInfo Load(string imagePath) + internal static AndroidLogcatCaptureInfo Load(string imagePath) { var path = PathFor(imagePath); if (string.IsNullOrEmpty(path) || !File.Exists(path)) @@ -201,7 +202,7 @@ internal static AndroidLogcatScreenshotInfo Load(string imagePath) try { - var info = JsonUtility.FromJson(File.ReadAllText(path)); + var info = JsonUtility.FromJson(File.ReadAllText(path)); // A file of someone else's that shares the name is not details, and // its defaults would be shown as a device of empty strings and zeroes. return IsDetails(info) ? info : null; diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs.meta b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureInfo.cs.meta similarity index 100% rename from com.unity.mobile.android-logcat/Editor/AndroidLogcatScreenshotInfo.cs.meta rename to com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureInfo.cs.meta diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs index 90b37e9f..d841afca 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureList.cs @@ -549,12 +549,12 @@ internal class PreviewDetails internal string[] Values { get; } // A recording's changes split by kind, each in time order, so a lookup is a // binary search rather than a walk past every touch of a long recording. - readonly AndroidLogcatScreenshotInfo.FrameChange[] m_DisplayChanges; - readonly AndroidLogcatScreenshotInfo.FrameChange[] m_ContentChanges; - readonly AndroidLogcatScreenshotInfo.FrameChange[] m_TouchChanges; + readonly AndroidLogcatCaptureInfo.FrameChange[] m_DisplayChanges; + readonly AndroidLogcatCaptureInfo.FrameChange[] m_ContentChanges; + readonly AndroidLogcatCaptureInfo.FrameChange[] m_TouchChanges; /// A recording has no texture, so it has no image size either. - internal PreviewDetails(Texture2D texture, FileInfo file, AndroidLogcatScreenshotInfo info) + internal PreviewDetails(Texture2D texture, FileInfo file, AndroidLogcatCaptureInfo info) { Device = info == null || string.IsNullOrEmpty(info.deviceName) ? kUndefined : info.deviceName; DeviceId = info?.deviceId; @@ -562,7 +562,7 @@ internal PreviewDetails(Texture2D texture, FileInfo file, AndroidLogcatScreensho DisplaySize = info == null || info.displayWidth <= 0 ? kUndefined : $"{info.displayWidth}x{info.displayHeight}"; - var changes = info?.frameChanges ?? Array.Empty(); + var changes = info?.frameChanges ?? Array.Empty(); m_DisplayChanges = Ordered(changes, change => change.display != null && change.display.IsSet); m_ContentChanges = Ordered(changes, change => change.content != null && change.content.IsSet); m_TouchChanges = Ordered(changes, change => change.touches != null && change.touches.Count > 0); @@ -629,15 +629,15 @@ internal bool TouchAt(double time, double fadeSeconds, out Vector2 position, out return true; } - static AndroidLogcatScreenshotInfo.FrameChange[] Ordered( - AndroidLogcatScreenshotInfo.FrameChange[] changes, Func has) + static AndroidLogcatCaptureInfo.FrameChange[] Ordered( + AndroidLogcatCaptureInfo.FrameChange[] changes, Func has) { // Stable, as recordings made before the recorder kept them in order may not be. return changes.Where(change => change != null && has(change)).OrderBy(change => change.time).ToArray(); } /// The last of at or before , or null. - static AndroidLogcatScreenshotInfo.FrameChange LatestAt(AndroidLogcatScreenshotInfo.FrameChange[] changes, double time) + static AndroidLogcatCaptureInfo.FrameChange LatestAt(AndroidLogcatCaptureInfo.FrameChange[] changes, double time) { // A hair early, so the frame a change lands on already shows it. time += 0.0005; @@ -654,7 +654,7 @@ static AndroidLogcatScreenshotInfo.FrameChange LatestAt(AndroidLogcatScreenshotI } } - static string OperatingSystem(AndroidLogcatScreenshotInfo info) + static string OperatingSystem(AndroidLogcatCaptureInfo info) { if (string.IsNullOrEmpty(info.osVersion)) return info.apiLevel > 0 ? $"API {info.apiLevel}" : kUndefined; @@ -682,7 +682,7 @@ internal void SyncPreview() m_LogView = null; if (IsVideo(path)) { - var info = AndroidLogcatScreenshotInfo.Load(path); + var info = AndroidLogcatCaptureInfo.Load(path); m_PreviewDetails = new PreviewDetails(null, new FileInfo(path), info); m_LogView = new AndroidLogcatRecordingLogView(m_Runtime, info?.frameChanges); m_VideoPlayer.Open(path, m_RestoreVideoFrame); @@ -699,7 +699,7 @@ internal void SyncPreview() { m_PreviewTexture = texture; m_PreviewDetails = new PreviewDetails(texture, new FileInfo(path), - AndroidLogcatScreenshotInfo.Load(path)); + AndroidLogcatCaptureInfo.Load(path)); } else { diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureScreenshot.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureScreenshot.cs index 8f4d5b64..1e42db45 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureScreenshot.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureScreenshot.cs @@ -27,7 +27,7 @@ internal class AndroidLogcatCaptureScreenCaptureResult : IAndroidLogcatTaskResul internal string reservedPath; internal string deviceId; internal string error; - internal AndroidLogcatScreenshotInfo info; + internal AndroidLogcatCaptureInfo info; internal int quarterTurns; internal Action onCompleted; } @@ -197,7 +197,7 @@ private string AllocateSinglePath(string directory, string prefix, string extens if (screenshot.Path == path || m_ReservedPaths.Contains(screenshot.Path)) continue; DeleteQuietly(screenshot.Path); - AndroidLogcatScreenshotInfo.Delete(screenshot.Path); + AndroidLogcatCaptureInfo.Delete(screenshot.Path); } m_ReservedPaths.Add(path); @@ -347,10 +347,10 @@ public bool RenameScreenshot(string path, string newName, out string renamed) } // Checked before the image moves, so the two cannot end up apart. - if (!AndroidLogcatScreenshotInfo.CanWriteBeside(target)) + if (!AndroidLogcatCaptureInfo.CanWriteBeside(target)) { UnityEngine.Debug.LogError( - $"'{Path.GetFileName(AndroidLogcatScreenshotInfo.PathFor(target))}' already exists " + + $"'{Path.GetFileName(AndroidLogcatCaptureInfo.PathFor(target))}' already exists " + "and was not written by Android Logcat. Choose a different name."); return false; } @@ -365,7 +365,7 @@ public bool RenameScreenshot(string path, string newName, out string renamed) return false; } - AndroidLogcatScreenshotInfo.Move(path, target); + AndroidLogcatCaptureInfo.Move(path, target); // Rescan, so the list picks up the new name and reorders. InvalidateScreenshots(); @@ -396,7 +396,7 @@ public bool DeleteScreenshot(string path) return false; } - AndroidLogcatScreenshotInfo.Delete(path); + AndroidLogcatCaptureInfo.Delete(path); // Rescan, so the list loses the row. InvalidateScreenshots(); @@ -488,7 +488,7 @@ private static IAndroidLogcatTaskResult ExecuteScreenCapture(IAndroidLogcatTaskI error = error, // Read here because it asks the device; written on the main thread, // where JsonUtility is safe to call. - info = result ? AndroidLogcatScreenshotInfo.Create(i.device) : null, + info = result ? AndroidLogcatCaptureInfo.Create(i.device) : null, quarterTurns = i.quarterTurns, onCompleted = i.onCompleted }; diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs index 39d189fd..ccdd2749 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs @@ -104,7 +104,7 @@ internal void StartRecording(IAndroidLogcatDevice device, Action RecordingPath = path; m_Recorder = recorder; // The same details a screenshot is saved with, so the list can say which device it came from. - AndroidLogcatScreenshotInfo.Create(device)?.Save(RecordingPath); + AndroidLogcatCaptureInfo.Create(device)?.Save(RecordingPath); m_OnStopRecording = onStopRecording; m_Clock.Restart(); stream.Recorder = m_Recorder; @@ -179,11 +179,11 @@ internal bool StopRecording() /// Folding or turning the device during a recording changes its display, so the /// details saved at the start get what changed over time. /// - static void SaveFrameChanges(string path, IReadOnlyList changes) + static void SaveFrameChanges(string path, IReadOnlyList changes) { if (changes.Count == 0) return; - var info = AndroidLogcatScreenshotInfo.Load(path); + var info = AndroidLogcatCaptureInfo.Load(path); if (info == null) return; var first = changes[0].display; @@ -192,7 +192,7 @@ static void SaveFrameChanges(string path, IReadOnlyList m_Entries.Length > 0; - internal AndroidLogcatRecordingLogView(AndroidLogcatRuntimeBase runtime, AndroidLogcatScreenshotInfo.FrameChange[] changes) + internal AndroidLogcatRecordingLogView(AndroidLogcatRuntimeBase runtime, AndroidLogcatCaptureInfo.FrameChange[] changes) { m_Runtime = runtime; - var rows = (changes ?? Array.Empty()) + var rows = (changes ?? Array.Empty()) .Where(change => change?.logs != null) .OrderBy(change => change.time) .SelectMany(change => change.logs.Select(entry => (change.time, entry))) diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs index 53864158..a78be66f 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs @@ -80,15 +80,15 @@ struct QueuedFrame // The live view's texture the recording started from, until a frame is decoded. Texture2D m_Seed; readonly int m_Side; - readonly List m_FrameChanges = - new List(); + readonly List m_FrameChanges = + new List(); // The display and the picture's place in the video, as the last change set them. int m_DisplayWidth; int m_DisplayHeight; RectInt m_Content; /// What changed over the recording, from its start. - internal IReadOnlyList FrameChanges => m_FrameChanges; + internal IReadOnlyList FrameChanges => m_FrameChanges; long m_FirstPtsUs = -1; // Where the first device frame lands on the recording's clock. long m_FirstArrivalUs; @@ -410,7 +410,7 @@ internal void NoteTouch(AndroidLogcatLiveStream.TouchAction action, float x, flo last.y = y; return; } - touches.Add(new AndroidLogcatScreenshotInfo.TouchInfo { action = name, x = x, y = y }); + touches.Add(new AndroidLogcatCaptureInfo.TouchInfo { action = name, x = x, y = y }); } /// Where Compose puts a frame in the video, so a player can leave out the black. @@ -441,7 +441,7 @@ void NoteContent(int sourceWidth, int sourceHeight, int turns, long slot) /// Not always last: a touch is timed when it is sent, while a frame still queued is /// timed by its slot, which can be earlier. /// - AndroidLogcatScreenshotInfo.FrameChange ChangeAt(double time) + AndroidLogcatCaptureInfo.FrameChange ChangeAt(double time) { var index = m_FrameChanges.Count; while (index > 0 && m_FrameChanges[index - 1].time > time) @@ -449,7 +449,7 @@ AndroidLogcatScreenshotInfo.FrameChange ChangeAt(double time) // Times are slots over the frame rate, so the same slot gives the same time exactly. if (index > 0 && m_FrameChanges[index - 1].time == time) return m_FrameChanges[index - 1]; - var change = new AndroidLogcatScreenshotInfo.FrameChange { time = time }; + var change = new AndroidLogcatCaptureInfo.FrameChange { time = time }; m_FrameChanges.Insert(index, change); return change; } diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatUtilities.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatUtilities.cs index 90469595..2c9dbecf 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatUtilities.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatUtilities.cs @@ -157,7 +157,7 @@ public static string SaveFileAs(string sourcePath, string title, string startDir // A screenshot's details file goes with the copy. Nothing to do for a // file that has none, which is every video. - AndroidLogcatScreenshotInfo.CopyBeside(sourcePath, path); + AndroidLogcatCaptureInfo.CopyBeside(sourcePath, path); return Path.GetFullPath(Path.GetDirectoryName(path)); } @@ -180,7 +180,7 @@ public static bool CopyInto(string sourcePath, string directory) return false; } - AndroidLogcatScreenshotInfo.CopyBeside(sourcePath, target); + AndroidLogcatCaptureInfo.CopyBeside(sourcePath, target); return true; } diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs index a6bf4ea5..66c87cdc 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatGeneralTests.cs @@ -188,7 +188,7 @@ public void RenameIsRefusedWhenAnotherKindOfCaptureHasTheName() System.IO.File.WriteAllBytes(image, new byte[] { 1, 2, 3 }); System.IO.File.WriteAllBytes(recording, new byte[] { 4, 5, 6 }); - new AndroidLogcatScreenshotInfo { deviceName = "The recording's device" }.Save(recording); + new AndroidLogcatCaptureInfo { deviceName = "The recording's device" }.Save(recording); var recordingDetails = System.IO.File.ReadAllText(details); try @@ -459,7 +459,7 @@ public void LiveStreamServerJarIsBuilt() /// the same calls, and the rest is a file next to a file. /// [Test] - public void ScreenshotInfoRoundTripsAndFollowsTheImage() + public void CaptureInfoRoundTripsAndFollowsTheImage() { var directory = CreateCapturesFolder(); @@ -469,13 +469,13 @@ public void ScreenshotInfoRoundTripsAndFollowsTheImage() try { - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(image), + Assert.IsNull(AndroidLogcatCaptureInfo.Load(image), "A screenshot with no details file has nothing to read"); var device = new AndroidLogcatFakeDevice90("unittest-device"); device.SetRawDisplayInfo("Physical size: 1080x2400\nOverride size: 540x1200"); - var info = AndroidLogcatScreenshotInfo.Create(device); + var info = AndroidLogcatCaptureInfo.Create(device); Assert.AreEqual("unittest-device", info.deviceId); // An overridden size is what the device composes, so that is what a // screenshot of it was taken at. @@ -483,32 +483,32 @@ public void ScreenshotInfoRoundTripsAndFollowsTheImage() Assert.AreEqual(1200, info.displayHeight); info.Save(image); - FileAssert.Exists(AndroidLogcatScreenshotInfo.PathFor(image)); + FileAssert.Exists(AndroidLogcatCaptureInfo.PathFor(image)); - var loaded = AndroidLogcatScreenshotInfo.Load(image); - Assert.AreEqual(AndroidLogcatScreenshotInfo.kVersion, loaded.version); + var loaded = AndroidLogcatCaptureInfo.Load(image); + Assert.AreEqual(AndroidLogcatCaptureInfo.kVersion, loaded.version); Assert.AreEqual(info.deviceId, loaded.deviceId); Assert.AreEqual(info.deviceName, loaded.deviceName); Assert.AreEqual(info.capturedAt, loaded.capturedAt); Assert.AreEqual(info.displayWidth, loaded.displayWidth); Assert.AreEqual(info.displayHeight, loaded.displayHeight); - AndroidLogcatScreenshotInfo.Move(image, renamed); - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(image), + AndroidLogcatCaptureInfo.Move(image, renamed); + Assert.IsNull(AndroidLogcatCaptureInfo.Load(image), "The details should have moved with the image"); - Assert.AreEqual(info.deviceId, AndroidLogcatScreenshotInfo.Load(renamed).deviceId); + Assert.AreEqual(info.deviceId, AndroidLogcatCaptureInfo.Load(renamed).deviceId); - AndroidLogcatScreenshotInfo.Delete(renamed); - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(renamed)); + AndroidLogcatCaptureInfo.Delete(renamed); + Assert.IsNull(AndroidLogcatCaptureInfo.Load(renamed)); // The details take the image's name with a .json extension, which is a // name someone else's file can already have - saving a capture as // settings.png beside an unrelated settings.json must not eat it. - var foreignJson = AndroidLogcatScreenshotInfo.PathFor(foreign); + var foreignJson = AndroidLogcatCaptureInfo.PathFor(foreign); const string keep = "{\"keep\":\"me\"}"; System.IO.File.WriteAllText(foreignJson, keep); - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(foreign), + Assert.IsNull(AndroidLogcatCaptureInfo.Load(foreign), "Someone else's json is not a details file"); LogAssert.Expect(LogType.Warning, new Regex("not written by Android Logcat")); @@ -517,7 +517,7 @@ public void ScreenshotInfoRoundTripsAndFollowsTheImage() "Saving details should not overwrite a file we did not write"); LogAssert.Expect(LogType.Warning, new Regex("not written by Android Logcat")); - AndroidLogcatScreenshotInfo.Delete(foreign); + AndroidLogcatCaptureInfo.Delete(foreign); FileAssert.Exists(foreignJson); } finally diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRecordingLookupTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRecordingLookupTests.cs index 487e7172..9d2f644f 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRecordingLookupTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRecordingLookupTests.cs @@ -38,26 +38,26 @@ public void TearDown() public void LookupsNearTheEndOfALongRecordingStayWithinBudget() { var frames = kFrameRate * 60 * kMinutes; - var changes = new AndroidLogcatScreenshotInfo.FrameChange[frames]; + var changes = new AndroidLogcatCaptureInfo.FrameChange[frames]; for (var i = 0; i < frames; i++) { - var change = new AndroidLogcatScreenshotInfo.FrameChange { time = (double)i / kFrameRate }; + var change = new AndroidLogcatCaptureInfo.FrameChange { time = (double)i / kFrameRate }; var action = i == 0 ? AndroidLogcatLiveStream.TouchAction.Down : AndroidLogcatLiveStream.TouchAction.Move; - change.touches.Add(new AndroidLogcatScreenshotInfo.TouchInfo { action = action.ToString(), x = (i % 100) / 100f, y = 0.5f }); + change.touches.Add(new AndroidLogcatCaptureInfo.TouchInfo { action = action.ToString(), x = (i % 100) / 100f, y = 0.5f }); changes[i] = change; } // Folded at the start, unfolded at a minute in, then only touches: the slowest // case for finding the latest display change. - changes[0].display = new AndroidLogcatScreenshotInfo.DisplayInfo { width = 1080, height = 2424 }; - changes[0].content = new AndroidLogcatScreenshotInfo.ContentInfo { x = 284, y = 0, width = 456, height = 1024 }; + changes[0].display = new AndroidLogcatCaptureInfo.DisplayInfo { width = 1080, height = 2424 }; + changes[0].content = new AndroidLogcatCaptureInfo.ContentInfo { x = 284, y = 0, width = 456, height = 1024 }; var unfold = kFrameRate * 60; - changes[unfold].display = new AndroidLogcatScreenshotInfo.DisplayInfo { width = 2076, height = 2152 }; - changes[unfold].content = new AndroidLogcatScreenshotInfo.ContentInfo { x = 18, y = 0, width = 988, height = 1024 }; + changes[unfold].display = new AndroidLogcatCaptureInfo.DisplayInfo { width = 2076, height = 2152 }; + changes[unfold].content = new AndroidLogcatCaptureInfo.ContentInfo { x = 18, y = 0, width = 988, height = 1024 }; - var info = new AndroidLogcatScreenshotInfo { displayWidth = 1080, displayHeight = 2424, frameChanges = changes }; + var info = new AndroidLogcatCaptureInfo { displayWidth = 1080, displayHeight = 2424, frameChanges = changes }; var json = JsonUtility.ToJson(info); var load = Stopwatch.StartNew(); - info = JsonUtility.FromJson(json); + info = JsonUtility.FromJson(json); load.Stop(); var details = new AndroidLogcatCaptureList.PreviewDetails(null, new FileInfo(m_File), info); diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs index d60e8662..5d67460b 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs @@ -109,8 +109,8 @@ public void LogsLandOnTheFrameTheyWereLoggedBeforeAndSurviveSaving() var after = logged.Single(change => change.logs.Any(entry => entry.message == "after it stopped")); Assert.AreEqual(last, after.time, "A message after the last frame should land on the last frame"); - var info = new AndroidLogcatScreenshotInfo { frameChanges = recorder.FrameChanges.ToArray() }; - var loaded = JsonUtility.FromJson(JsonUtility.ToJson(info)); + var info = new AndroidLogcatCaptureInfo { frameChanges = recorder.FrameChanges.ToArray() }; + var loaded = JsonUtility.FromJson(JsonUtility.ToJson(info)); var saved = loaded.frameChanges.SelectMany(change => change.logs).Single(entry => entry.message == "two frames in"); Assert.AreEqual(kFrameRealtimeUs + 2 * kFrameUs, (saved.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10); Assert.AreEqual(Priority.Warn, saved.priority); diff --git a/com.unity.mobile.android-logcat/Tests/Editor/Integration/AndroidLogcatIntegrationScreenCapture.cs b/com.unity.mobile.android-logcat/Tests/Editor/Integration/AndroidLogcatIntegrationScreenCapture.cs index 3330b0ce..5dbd3860 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/Integration/AndroidLogcatIntegrationScreenCapture.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/Integration/AndroidLogcatIntegrationScreenCapture.cs @@ -102,12 +102,12 @@ public IEnumerator CanGetScreenshot() var path = Runtime.CaptureScreenshot.GetLatestImagePath(Device); CopyToArtifacts("screenshot.png", path); - var info = AndroidLogcatScreenshotInfo.Load(path); + var info = AndroidLogcatCaptureInfo.Load(path); Assert.IsNotNull(info, "Expected details to be saved beside the screenshot"); Assert.AreEqual(Device.Id, info.deviceId); Assert.AreEqual(Device.APILevel, info.apiLevel); Assert.Greater(info.displayWidth, 0, $"Expected a display size, got {info.displayWidth}x{info.displayHeight}"); - CopyToArtifacts("screenshot.json", AndroidLogcatScreenshotInfo.PathFor(path)); + CopyToArtifacts("screenshot.json", AndroidLogcatCaptureInfo.PathFor(path)); } /// @@ -179,7 +179,7 @@ public IEnumerator CanDeleteScreenshot() Assert.IsTrue(Runtime.CaptureScreenshot.DeleteScreenshot(path), "Delete should have succeeded"); Assert.IsFalse(File.Exists(path), "The file should be gone from disk"); - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(path), "Its details should go with it"); + Assert.IsNull(AndroidLogcatCaptureInfo.Load(path), "Its details should go with it"); Assert.AreEqual(before - 1, Runtime.CaptureScreenshot.GetScreenshots().Count, "The list should have lost the row"); // It was the displayed one, so the image is cleared rather than left pointing at @@ -221,8 +221,8 @@ public IEnumerator CanRenameScreenshot() Assert.AreEqual(renamed, Runtime.CaptureScreenshot.SelectedImagePath, "The displayed image should follow the rename"); - Assert.IsNull(AndroidLogcatScreenshotInfo.Load(path), "The details should not be left behind"); - Assert.IsNotNull(AndroidLogcatScreenshotInfo.Load(renamed), "The details should follow the image"); + Assert.IsNull(AndroidLogcatCaptureInfo.Load(path), "The details should not be left behind"); + Assert.IsNotNull(AndroidLogcatCaptureInfo.Load(renamed), "The details should follow the image"); var entry = screenshots.First(s => s.Path == renamed); Assert.AreEqual(newName, entry.Name); From f7baf488c49e8385c85e874cb5e145bc3b60a514 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:36:40 +0200 Subject: [PATCH 05/10] Draw the recording's logcat messages like the Android Logcat window The panel under the video now uses the Logcat window's column header, row stripes, selection highlight for the shown frame, priority icons, and the message font and colors from Preferences. The shared columns follow the Logcat window's column widths and visibility, with the video time first. Co-Authored-By: Claude Opus 5.5 --- .../Documentation~/screen-capture-video.md | 2 +- .../Editor/AndroidLogcatRecordingLogView.cs | 186 ++++++++++++++---- 2 files changed, 154 insertions(+), 34 deletions(-) diff --git a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md index ef694be8..323de9cd 100644 --- a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md +++ b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md @@ -26,7 +26,7 @@ A recording can also save the logcat messages the device logs while you record, The recording saves the messages the [Android Logcat window](android-logcat-window.md) would display: the selected package, priority, tags, and filter text when recording starts. The messages are saved in the `.json` file next to the recording. -When you play the recording in the [Capture preview](screen-capture-window-reference.md#capture-preview), the messages appear in a panel under the video. Each message belongs to the first frame captured after it was logged, and starts with that frame's time in the video, as the player displays it, followed by the time on the device. The messages of the current frame, logged since the previous frame, are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. Drag the divider above the panel to resize it. +When you play the recording in the [Capture preview](screen-capture-window-reference.md#capture-preview), the messages appear in a panel under the video, with the same columns, colors, and font as the Android Logcat window. Each message belongs to the first frame captured after it was logged, and the **Video** column shows that frame's time in the video, as the player displays it. The messages of the current frame, logged since the previous frame, are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. Drag the divider above the panel to resize it. ## Recording limitations diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs index 3ec33379..e36625f3 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs @@ -19,27 +19,43 @@ static class Styles { internal static readonly GUIContent Title = new GUIContent("Logcat Messages", "Logged while recording, filtered as the Android Logcat window was when recording started. " + - "Each message starts with the video time of its frame, then the device's time. " + + "Video is the time of the frame each message belongs to. " + "Highlighted: logged since the previous frame. Click a message to go to its frame."); - internal static readonly GUIStyle Row = new GUIStyle(EditorStyles.miniLabel) { clipping = TextClipping.Clip }; - internal static readonly Color Current = new Color(0.24f, 0.48f, 0.9f, 0.35f); + internal static readonly GUIContent Video = new GUIContent("Video", "The time into the video of the frame the message belongs to."); + } + + // The Logcat window's columns, with the video time first. The shared ones take + // their width and visibility from the Logcat window's settings, so both line up. + enum Column + { + Icon, + Video, + Time, + ProcessId, + ThreadId, + Priority, + Tag, + Message } - const float kRowHeight = 16; const float kSplitterHeight = 5; const float kMinHeight = 60; const float kMinVideoHeight = 100; const float kDefaultHeight = 160; - // The time into the video, as the player shows it, then the device's clock. - const float kVideoTimeWidth = 56; - const float kTimeWidth = 84; - const float kPriorityWidth = 14; - const float kTagWidth = 150; - const float kColumnGap = 6; + const float kVideoTimeWidth = 60; + // As the Logcat window indents a column's text. + const float kTextMargin = 5; const float kScrollbarWidth = 16; // Rows after the shown frame, which the video has not reached. const float kFutureAlpha = 0.45f; + // The Logcat window's message styles with the font and colours from Preferences, + // which only that window applies to its own. + readonly GUIStyle[] m_PriorityStyles = new GUIStyle[Enum.GetValues(typeof(Priority)).Length]; + readonly float[] m_ColumnX = new float[Enum.GetValues(typeof(Column)).Length]; + readonly float[] m_ColumnWidth = new float[Enum.GetValues(typeof(Column)).Length]; + float m_RowHeight; + readonly LogcatEntry[] m_Entries; // The time of the frame each message belongs to, in order. readonly double[] m_FrameTimes; @@ -91,11 +107,15 @@ internal Rect DoGUI(Rect area, double time, double frameDuration, Action var first = FirstAtOrAfter(time - tolerance); var end = FirstAtOrAfter(time + tolerance); - var header = new Rect(panel.x, panel.y, panel.width, EditorGUIUtility.singleLineHeight); - GUI.Label(header, Styles.Title, EditorStyles.miniBoldLabel); + var title = new Rect(panel.x, panel.y, panel.width, EditorGUIUtility.singleLineHeight); + GUI.Label(title, Styles.Title, EditorStyles.miniBoldLabel); var count = new GUIContent($"{end - first} at this frame, {m_Entries.Length} in all"); var countWidth = EditorStyles.miniLabel.CalcSize(count).x; - GUI.Label(new Rect(header.xMax - countWidth - kColumnGap, header.y, countWidth, header.height), count, EditorStyles.miniLabel); + GUI.Label(new Rect(title.xMax - countWidth - kTextMargin, title.y, countWidth, title.height), count, EditorStyles.miniLabel); + + ApplySettings(); + var header = new Rect(panel.x, title.yMax, panel.width, AndroidLogcatStyles.columnHeader.CalcHeight(GUIContent.none, panel.width)); + DoHeaderGUI(header); var list = new Rect(panel.x, header.yMax, panel.width, Mathf.Max(0, panel.yMax - header.yMax)); FollowFrame(list, time, first, end); @@ -160,25 +180,97 @@ void FollowFrame(Rect list, double time, int first, int end) m_Scroll.y = 0; return; } - var top = Mathf.Max(0, first < end ? first : last) * kRowHeight; - var bottom = (last + 1) * kRowHeight; + var top = Mathf.Max(0, first < end ? first : last) * m_RowHeight; + var bottom = (last + 1) * m_RowHeight; if (bottom - m_Scroll.y > list.height) m_Scroll.y = bottom - list.height; if (top < m_Scroll.y) m_Scroll.y = top; } + void ApplySettings() + { + var settings = m_Runtime.Settings; + m_RowHeight = settings.MessageFontSize + 5; + foreach (Priority priority in Enum.GetValues(typeof(Priority))) + { + var style = m_PriorityStyles[(int)priority] ??= new GUIStyle(AndroidLogcatStyles.priorityDefaultStyle); + style.font = settings.MessageFont; + style.fontSize = settings.MessageFontSize; + style.fixedHeight = 0; + style.normal.textColor = settings.GetMessageColor(priority); + } + } + + bool Shows(Column column) + { + if (column == Column.Video) + return true; + var data = m_Runtime.Settings.ColumnData[(int)ConsoleColumn(column)]; + // The Logcat window hides its icons when the font is too small for them. + if (column == Column.Icon) + return m_Runtime.Settings.MessageFontSize > 11 && data.enabled; + return data.enabled; + } + + static AndroidLogcatConsoleWindow.Column ConsoleColumn(Column column) + { + switch (column) + { + case Column.Icon: return AndroidLogcatConsoleWindow.Column.Icon; + case Column.Time: return AndroidLogcatConsoleWindow.Column.Time; + case Column.ProcessId: return AndroidLogcatConsoleWindow.Column.ProcessId; + case Column.ThreadId: return AndroidLogcatConsoleWindow.Column.ThreadId; + case Column.Priority: return AndroidLogcatConsoleWindow.Column.Priority; + case Column.Tag: return AndroidLogcatConsoleWindow.Column.Tag; + default: return AndroidLogcatConsoleWindow.Column.Message; + } + } + + static GUIContent HeaderFor(Column column) + { + switch (column) + { + case Column.Video: return Styles.Video; + case Column.Icon: return GUIContent.none; + case Column.ProcessId: return new GUIContent("Pid"); + case Column.ThreadId: return new GUIContent("Tid"); + default: return new GUIContent(column.ToString()); + } + } + + /// The header, which also places the columns for the rows under it. The message takes what is left. + void DoHeaderGUI(Rect header) + { + var x = 0f; + foreach (Column column in Enum.GetValues(typeof(Column))) + { + m_ColumnX[(int)column] = x; + if (!Shows(column)) + { + m_ColumnWidth[(int)column] = 0; + continue; + } + var width = column == Column.Video ? kVideoTimeWidth + : column == Column.Message ? Mathf.Max(0, header.width - x) + : m_Runtime.Settings.ColumnData[(int)ConsoleColumn(column)].width; + m_ColumnWidth[(int)column] = width; + GUI.Label(new Rect(header.x + x, header.y, width, header.height), HeaderFor(column), AndroidLogcatStyles.columnHeader); + x += width; + } + } + void DoRowsGUI(Rect list, int first, int end, Action seek) { - var content = new Rect(0, 0, list.width - kScrollbarWidth, m_Entries.Length * kRowHeight); + var content = new Rect(0, 0, list.width - kScrollbarWidth, m_Entries.Length * m_RowHeight); m_Scroll = GUI.BeginScrollView(list, m_Scroll, content, false, true); - var from = Mathf.Max(0, Mathf.FloorToInt(m_Scroll.y / kRowHeight)); - var to = Mathf.Min(m_Entries.Length, Mathf.CeilToInt((m_Scroll.y + list.height) / kRowHeight) + 1); + var from = Mathf.Max(0, Mathf.FloorToInt(m_Scroll.y / m_RowHeight)); + var to = Mathf.Min(m_Entries.Length, Mathf.CeilToInt((m_Scroll.y + list.height) / m_RowHeight) + 1); var e = Event.current; var color = GUI.color; for (var i = from; i < to; i++) { - var row = new Rect(0, i * kRowHeight, content.width, kRowHeight); + var row = new Rect(0, i * m_RowHeight, content.width, m_RowHeight); if (e.type == EventType.MouseDown && e.button == 0 && row.Contains(e.mousePosition)) { seek(m_FrameTimes[i]); @@ -186,8 +278,11 @@ void DoRowsGUI(Rect list, int first, int end, Action seek) } if (e.type != EventType.Repaint) continue; + // The Logcat window's stripes, and its selection for the shown frame. if (i >= first && i < end) - EditorGUI.DrawRect(row, Styles.Current); + AndroidLogcatStyles.background.Draw(row, false, false, true, false); + else + (i % 2 == 0 ? AndroidLogcatStyles.backgroundEven : AndroidLogcatStyles.backgroundOdd).Draw(row, false, false, false, false); GUI.color = i >= end ? new Color(color.r, color.g, color.b, color.a * kFutureAlpha) : color; DoRowGUI(row, m_Entries[i], m_FrameTimes[i]); } @@ -197,19 +292,44 @@ void DoRowsGUI(Rect list, int first, int end, Action seek) void DoRowGUI(Rect row, LogcatEntry entry, double frameTime) { - var style = Styles.Row; - style.normal.textColor = m_Runtime.Settings.GetMessageColor(entry.priority); - var x = row.x + kColumnGap; - GUI.Label(new Rect(x, row.y, kVideoTimeWidth, row.height), - AndroidLogcatVideoPlayer.FormatTime(frameTime, m_Minutes), style); - x += kVideoTimeWidth; - GUI.Label(new Rect(x, row.y, kTimeWidth, row.height), entry.dateTime.ToLocalTime().ToString("HH:mm:ss.fff"), style); - x += kTimeWidth; - GUI.Label(new Rect(x, row.y, kPriorityWidth, row.height), entry.priority.ToString().Substring(0, 1), style); - x += kPriorityWidth + kColumnGap; - GUI.Label(new Rect(x, row.y, kTagWidth, row.height), entry.tag, style); - x += kTagWidth + kColumnGap; - GUI.Label(new Rect(x, row.y, Mathf.Max(0, row.xMax - x), row.height), new GUIContent(entry.message, entry.message), style); + var style = m_PriorityStyles[(int)entry.priority]; + if (Shows(Column.Icon)) + { + var iconSize = AndroidLogcatStyles.kSmallIconSize; + var icon = new Rect(m_ColumnX[(int)Column.Icon] + (m_ColumnWidth[(int)Column.Icon] - iconSize.x) * 0.5f, + row.y + (row.height - iconSize.y) * 0.5f, 0, 0); + IconStyleFor(entry.priority).Draw(icon, GUIContent.none, 0); + } + DoCellGUI(row, Column.Video, AndroidLogcatVideoPlayer.FormatTime(frameTime, m_Minutes), style); + DoCellGUI(row, Column.Time, entry.dateTime.ToLocalTime().ToString(LogcatEntry.s_TimeFormat), style); + DoCellGUI(row, Column.ProcessId, entry.processId.ToString(), style); + DoCellGUI(row, Column.ThreadId, entry.threadId.ToString(), style); + DoCellGUI(row, Column.Priority, entry.priority.ToString(), style); + DoCellGUI(row, Column.Tag, entry.tag, style); + DoCellGUI(row, Column.Message, entry.message, style); + } + + void DoCellGUI(Rect row, Column column, string value, GUIStyle style) + { + var width = m_ColumnWidth[(int)column]; + if (width <= kTextMargin) + return; + var cell = new Rect(m_ColumnX[(int)column] + kTextMargin, row.y, width - kTextMargin, row.height); + style.Draw(cell, new GUIContent(value), 0); + } + + static GUIStyle IconStyleFor(Priority priority) + { + switch (priority) + { + case Priority.Warn: + return AndroidLogcatStyles.warningSmallStyle; + case Priority.Error: + case Priority.Fatal: + return AndroidLogcatStyles.errorSmallStyle; + default: + return AndroidLogcatStyles.infoSmallStyle; + } } /// The first message belonging to a frame at or after . From b54eab35f7a59ca16617ed36602496bb61b36e67 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:37:40 +0200 Subject: [PATCH 06/10] Update the sample scene Saved by a newer Editor, with the DebugMethods object that shows typed characters. Co-Authored-By: Claude Opus 5.5 --- .../Assets/Scenes/SampleScene.unity | 157 +++++++++++++++--- 1 file changed, 134 insertions(+), 23 deletions(-) diff --git a/TestProjects/SampleProject1/Assets/Scenes/SampleScene.unity b/TestProjects/SampleProject1/Assets/Scenes/SampleScene.unity index 268c3825..9b8c3f18 100644 --- a/TestProjects/SampleProject1/Assets/Scenes/SampleScene.unity +++ b/TestProjects/SampleProject1/Assets/Scenes/SampleScene.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 9 + serializedVersion: 10 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -38,13 +38,12 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.44657892, g: 0.4964127, b: 0.5748172, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 11 - m_GIWorkflowMode: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 1 m_GISettings: serializedVersion: 2 m_BounceScale: 1 @@ -54,7 +53,7 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 0 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 10 m_AtlasSize: 512 @@ -62,13 +61,11 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 m_ReflectionCompression: 2 m_MixedBakeMode: 2 m_BakeBackend: 1 @@ -76,27 +73,35 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 256 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_ExportTrainingData: 0 - m_LightingDataAsset: {fileID: 0} - m_UseShadowmask: 1 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 112000000, guid: 265bc1c86fbdd2f4899b2b6e486d1402, + type: 2} + m_LightingSettings: {fileID: 1762417842} --- !u!196 &4 NavMeshSettings: serializedVersion: 2 m_ObjectHideFlags: 0 m_BuildSettings: - serializedVersion: 2 + serializedVersion: 3 agentTypeID: 0 agentRadius: 0.5 agentHeight: 2 @@ -109,7 +114,9 @@ NavMeshSettings: cellSize: 0.16666667 manualTileSize: 0 tileSize: 256 - accuratePlacement: 0 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 m_NavMeshData: {fileID: 0} @@ -139,7 +146,6 @@ MonoBehaviour: m_GameObject: {fileID: 51870915} m_Enabled: 1 m_EditorHideFlags: 0 - m_GeneratorAsset: {fileID: 0} m_Script: {fileID: 11500000, guid: 961df270c63014bcb9cea06dd4726087, type: 3} m_Name: m_EditorClassIdentifier: @@ -150,12 +156,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 51870915} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &170076733 GameObject: @@ -182,7 +189,7 @@ Light: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 170076733} m_Enabled: 1 - serializedVersion: 9 + serializedVersion: 11 m_Type: 1 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 1 @@ -198,6 +205,24 @@ Light: m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -205,14 +230,22 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 1 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ForceVisible: 0 m_ShadowRadius: 0 m_ShadowAngle: 0 + m_LightUnit: 1 + m_LuxAtDistance: 1 + m_EnableSpotReflector: 1 --- !u!4 &170076735 Transform: m_ObjectHideFlags: 0 @@ -220,12 +253,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 170076733} + serializedVersion: 2 m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &534669902 GameObject: @@ -262,14 +296,22 @@ Camera: m_GameObject: {fileID: 534669902} m_Enabled: 1 serializedVersion: 2 - m_ClearFlags: 1 + m_ClearFlags: 2 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -303,10 +345,79 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 534669902} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!850595691 &1762417842 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Settings.lighting + serializedVersion: 9 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 512 + m_LightmapSizeFixed: 0 + m_UseMipmapLimits: 1 + m_BakeResolution: 10 + m_Padding: 2 + m_LightmapCompression: 3 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_EnableWorkerProcessBaking: 1 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 256 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentImportanceSampling: 0 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_RespectSceneVisibilityWhenBakingGI: 0 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 534669905} + - {fileID: 170076735} + - {fileID: 51870917} From 6b04ba362f6b4280d791c3a199dbbb9501a5a132 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 13 Nov 2026 16:49:59 +0200 Subject: [PATCH 07/10] Show the video time range a logcat message was logged in The Video column shows the range from the previous frame to the message's frame, and a message now goes to the first frame at or after it, so frame N lists exactly what was logged after frame N-1, up to frame N. Co-Authored-By: Claude Opus 5.5 --- .../Documentation~/screen-capture-video.md | 2 +- .../Editor/AndroidLogcatRecordingLogView.cs | 24 +++++++++++++++---- .../Editor/AndroidLogcatStreamRecorder.cs | 6 ++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md index 323de9cd..bc305856 100644 --- a/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md +++ b/com.unity.mobile.android-logcat/Documentation~/screen-capture-video.md @@ -26,7 +26,7 @@ A recording can also save the logcat messages the device logs while you record, The recording saves the messages the [Android Logcat window](android-logcat-window.md) would display: the selected package, priority, tags, and filter text when recording starts. The messages are saved in the `.json` file next to the recording. -When you play the recording in the [Capture preview](screen-capture-window-reference.md#capture-preview), the messages appear in a panel under the video, with the same columns, colors, and font as the Android Logcat window. Each message belongs to the first frame captured after it was logged, and the **Video** column shows that frame's time in the video, as the player displays it. The messages of the current frame, logged since the previous frame, are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. Drag the divider above the panel to resize it. +When you play the recording in the [Capture preview](screen-capture-window-reference.md#capture-preview), the messages appear in a panel under the video, with the same columns, colors, and font as the Android Logcat window. Each message belongs to the first frame captured after it was logged. The **Video** column shows when in the video the message was logged: after the previous frame, up to its own frame, in the time format of the player. The messages of the current frame, logged since the previous frame, are highlighted, and messages logged after the current frame are dimmed. Select a message to go to its frame. Drag the divider above the panel to resize it. ## Recording limitations diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs index e36625f3..f922b13f 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatRecordingLogView.cs @@ -19,9 +19,10 @@ static class Styles { internal static readonly GUIContent Title = new GUIContent("Logcat Messages", "Logged while recording, filtered as the Android Logcat window was when recording started. " + - "Video is the time of the frame each message belongs to. " + + "Video is the range of the video each message was logged in: after the previous frame, up to its frame. " + "Highlighted: logged since the previous frame. Click a message to go to its frame."); - internal static readonly GUIContent Video = new GUIContent("Video", "The time into the video of the frame the message belongs to."); + internal static readonly GUIContent Video = new GUIContent("Video", + "When in the video the message was logged: after the previous frame, up to the frame it belongs to."); } // The Logcat window's columns, with the video time first. The shared ones take @@ -42,7 +43,9 @@ enum Column const float kMinHeight = 60; const float kMinVideoHeight = 100; const float kDefaultHeight = 160; - const float kVideoTimeWidth = 60; + // Wide enough for a range, with minutes for a recording a minute or longer. + const float kVideoTimeWidth = 90; + const float kVideoTimeWithMinutesWidth = 115; // As the Logcat window indents a column's text. const float kTextMargin = 5; const float kScrollbarWidth = 16; @@ -61,6 +64,7 @@ enum Column readonly double[] m_FrameTimes; // With minutes, as the player shows a recording a minute or longer. readonly bool m_Minutes; + double m_FrameDuration; readonly AndroidLogcatRuntimeBase m_Runtime; Vector2 m_Scroll; float m_Height = kDefaultHeight; @@ -91,6 +95,7 @@ internal AndroidLogcatRecordingLogView(AndroidLogcatRuntimeBase runtime, Android /// Goes to the frame at a time, for a clicked message. internal Rect DoGUI(Rect area, double time, double frameDuration, Action seek) { + m_FrameDuration = frameDuration; // Clamped for this pass only: the layout pass hands a placeholder area, which // would shrink the height the user chose every time. var maxHeight = Mathf.Max(kMinHeight, area.height - kMinVideoHeight - kSplitterHeight); @@ -251,7 +256,7 @@ void DoHeaderGUI(Rect header) m_ColumnWidth[(int)column] = 0; continue; } - var width = column == Column.Video ? kVideoTimeWidth + var width = column == Column.Video ? (m_Minutes ? kVideoTimeWithMinutesWidth : kVideoTimeWidth) : column == Column.Message ? Mathf.Max(0, header.width - x) : m_Runtime.Settings.ColumnData[(int)ConsoleColumn(column)].width; m_ColumnWidth[(int)column] = width; @@ -300,7 +305,7 @@ void DoRowGUI(Rect row, LogcatEntry entry, double frameTime) row.y + (row.height - iconSize.y) * 0.5f, 0, 0); IconStyleFor(entry.priority).Draw(icon, GUIContent.none, 0); } - DoCellGUI(row, Column.Video, AndroidLogcatVideoPlayer.FormatTime(frameTime, m_Minutes), style); + DoCellGUI(row, Column.Video, VideoRange(frameTime), style); DoCellGUI(row, Column.Time, entry.dateTime.ToLocalTime().ToString(LogcatEntry.s_TimeFormat), style); DoCellGUI(row, Column.ProcessId, entry.processId.ToString(), style); DoCellGUI(row, Column.ThreadId, entry.threadId.ToString(), style); @@ -318,6 +323,15 @@ void DoCellGUI(Rect row, Column column, string value, GUIStyle style) style.Draw(cell, new GUIContent(value), 0); } + /// From the frame before to this one, as the player shows times: what a message on this frame was logged within. + string VideoRange(double frameTime) + { + var to = AndroidLogcatVideoPlayer.FormatTime(frameTime, m_Minutes); + if (frameTime <= 0 || m_FrameDuration <= 0) + return to; + return $"{AndroidLogcatVideoPlayer.FormatTime(Math.Max(0, frameTime - m_FrameDuration), m_Minutes)} - {to}"; + } + static GUIStyle IconStyleFor(Priority priority) { switch (priority) diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs index a78be66f..b499aa2e 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs @@ -379,8 +379,8 @@ internal void NoteLogs(IEnumerable entries) } /// - /// Each message goes to the frame whose slot it was logged in, so a frame lists - /// what was logged since the one before it. + /// Each message goes to the first frame at or after it, so frame N lists what was + /// logged after frame N-1, up to frame N. /// void PlaceLogs(long lastSlot) { @@ -389,7 +389,7 @@ void PlaceLogs(long lastSlot) foreach (var entry in m_Logs) { var realtimeUs = (entry.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10; - var slot = SlotAt(m_AnchorUs + realtimeUs - m_AnchorRealtimeUs); + var slot = (long)Math.Ceiling((m_AnchorUs + realtimeUs - m_AnchorRealtimeUs) * (double)m_FrameRate / 1000000); // Logged before the recording started. if (slot < 0) continue; From e0da2a7db1dc49b813c110cf0e81e441c857692b Mon Sep 17 00:00:00 2001 From: Tomas Date: Mon, 16 Nov 2026 14:42:40 +0200 Subject: [PATCH 08/10] Address review of logcat message placement - Read the recording's logcat from the device time of the frame recording started on (-T ), so messages logged while adb starts aren't missed. - Drop messages logged before the recording by their unrounded time, so one just before the start no longer lands on the first frame. - Place messages by sorting them by frame and merging them into the frame changes in one pass, instead of searching the changes for each message. Co-Authored-By: Claude Opus 5.5 --- .../Editor/AndroidLogcat.cs | 17 +++++-- .../Editor/AndroidLogcatCaptureVideo.cs | 5 +- .../Editor/AndroidLogcatStreamRecorder.cs | 47 +++++++++++++++---- .../AndroidLogcatStreamRecorderTests.cs | 4 +- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs index f0a1a204..d3d08c4a 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs @@ -21,6 +21,8 @@ internal class AndroidLogcat // Reading for a recording: messages from now on, stamped with the device's wall // clock so they can be placed among the frames. private readonly bool m_ForRecording; + // For a recording, the device wall clock to read messages from, -1 for the latest on. + private readonly long m_SinceRealtimeUs; private readonly LogcatFilterOptions m_FilterOptions; private FilterOptions m_LastUsedFilterOptions; private List m_RawLogEntries = new List(); @@ -126,7 +128,8 @@ public AndroidLogcat(AndroidLogcatRuntimeBase runtime, Priority priority, FilterOptions filterOptions, string[] tags, - bool forRecording = false) + bool forRecording = false, + long sinceRealtimeUs = -1) { this.m_Runtime = runtime; this.adb = adb; @@ -137,6 +140,7 @@ public AndroidLogcat(AndroidLogcatRuntimeBase runtime, this.m_LastUsedFilterOptions = new FilterOptions(m_FilterOptions); this.m_Tags = tags; this.m_ForRecording = forRecording; + this.m_SinceRealtimeUs = sinceRealtimeUs; m_FilterOptions.OnFilterChanged = OnFilterChanged; @@ -497,7 +501,9 @@ internal string LogPrintFormat get { if (m_ForRecording) - return kEpochFromNow; + return kEpoch + (m_SinceRealtimeUs > 0 + ? (m_SinceRealtimeUs / 1000000.0).ToString("0.000000", System.Globalization.CultureInfo.InvariantCulture) + : "1"); return m_Device.SupportYearFormat ? kYearTime : kThreadTime; } } @@ -520,8 +526,9 @@ internal string LogPrintFormat // Log PrintFormats internal const string kThreadTime = "threadtime"; internal const string kYearTime = "year"; - // Placed after '-v': seconds since the epoch to the microsecond, from the latest - // message on rather than the whole buffer. - internal const string kEpochFromNow = "epoch -v usec -T 1"; + // Placed after '-v': seconds since the epoch to the microsecond, from a time, or + // from the latest message, rather than the whole buffer. A time is in the same + // seconds, and catches what was logged while logcat was starting. + internal const string kEpoch = "epoch -v usec -T "; } } diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs index ccdd2749..0e5cc1ad 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatCaptureVideo.cs @@ -124,7 +124,10 @@ void StartLogcat(IAndroidLogcatDevice device, AndroidLogcatStreamRecorder record var process = user.LastSelectedProcess; var pid = process != null && process.deviceId == device.Id ? process.processId : 0; m_Logcat = new AndroidLogcat(m_Runtime, m_Runtime.Tools.ADB, device, pid, user.SelectedPriority, - user.FilterOptions, user.Tags.GetSelectedTags(), forRecording: true); + user.FilterOptions, user.Tags.GetSelectedTags(), forRecording: true, + // From the frame the recording started on, so nothing logged while adb + // was starting is missed. Earlier messages are left out when placed. + sinceRealtimeUs: m_Runtime.LiveStream.ShownRealtimeUs); m_Logcat.FilteredLogEntriesAdded += recorder.NoteLogs; m_Logcat.Start(); } diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs index b499aa2e..3808f540 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcatStreamRecorder.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using UnityEditor; using UnityEditor.Media; using Unity.Profiling; @@ -384,18 +385,46 @@ internal void NoteLogs(IEnumerable entries) /// void PlaceLogs(long lastSlot) { - if (m_AnchorRealtimeUs < 0 || lastSlot < 0) - return; - foreach (var entry in m_Logs) + var placed = new List<(long slot, LogcatEntry entry)>(m_Logs.Count); + if (m_AnchorRealtimeUs >= 0 && lastSlot >= 0) { - var realtimeUs = (entry.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10; - var slot = (long)Math.Ceiling((m_AnchorUs + realtimeUs - m_AnchorRealtimeUs) * (double)m_FrameRate / 1000000); - // Logged before the recording started. - if (slot < 0) - continue; - ChangeAt((double)Math.Min(slot, lastSlot) / m_FrameRate).logs.Add(entry); + foreach (var entry in m_Logs) + { + var realtimeUs = (entry.dateTime.Ticks - DateTime.UnixEpoch.Ticks) / 10; + var us = m_AnchorUs + realtimeUs - m_AnchorRealtimeUs; + // Logged before the recording started. + if (us < 0) + continue; + var slot = (long)Math.Ceiling(us * (double)m_FrameRate / 1000000); + placed.Add((Math.Min(slot, lastSlot), entry)); + } } m_Logs.Clear(); + if (placed.Count == 0) + return; + + // Merged with the changes in one pass: placing messages one at a time would + // search the changes for each. Stable, so a frame keeps its messages in order. + var ordered = placed.OrderBy(p => p.slot).ToList(); + var merged = new List(m_FrameChanges.Count + ordered.Count); + var next = 0; + for (var i = 0; i < ordered.Count;) + { + var slot = ordered[i].slot; + var time = (double)slot / m_FrameRate; + while (next < m_FrameChanges.Count && m_FrameChanges[next].time < time) + merged.Add(m_FrameChanges[next++]); + var change = next < m_FrameChanges.Count && m_FrameChanges[next].time == time + ? m_FrameChanges[next++] + : new AndroidLogcatCaptureInfo.FrameChange { time = time }; + merged.Add(change); + while (i < ordered.Count && ordered[i].slot == slot) + change.logs.Add(ordered[i++].entry); + } + while (next < m_FrameChanges.Count) + merged.Add(m_FrameChanges[next++]); + m_FrameChanges.Clear(); + m_FrameChanges.AddRange(merged); } internal void NoteTouch(AndroidLogcatLiveStream.TouchAction action, float x, float y) diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs index 5d67460b..00c1ec9d 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatStreamRecorderTests.cs @@ -89,6 +89,8 @@ public void LogsLandOnTheFrameTheyWereLoggedBeforeAndSurviveSaving() m_Recorder.NoteLogs(new[] { Log(kFrameRealtimeUs - 1000000, "before the recording"), + // Less than a frame before: rounding it up would put it on the first frame. + Log(kFrameRealtimeUs - 20000, "just before the recording"), Log(kFrameRealtimeUs + 2 * kFrameUs, "two frames in"), Log(kFrameRealtimeUs + 60 * 1000000L, "after it stopped") }); @@ -100,7 +102,7 @@ public void LogsLandOnTheFrameTheyWereLoggedBeforeAndSurviveSaving() Assert.IsTrue(recorder.Stop(), $"Nothing was recorded. {recorder.Error}"); var logged = recorder.FrameChanges.Where(change => change.logs.Count > 0).ToArray(); - Assert.IsFalse(logged.SelectMany(change => change.logs).Any(entry => entry.message == "before the recording"), + Assert.IsFalse(logged.SelectMany(change => change.logs).Any(entry => entry.message.EndsWith("before the recording")), "A message logged before the recording started should be left out"); var twoIn = logged.Single(change => change.logs.Any(entry => entry.message == "two frames in")); // Two frames after the only one, give or take how long queueing took. From 33a0551d96d038d906e259b28a232b8b16b0b8bd Mon Sep 17 00:00:00 2001 From: Tomas Date: Mon, 16 Nov 2026 14:43:48 +0200 Subject: [PATCH 09/10] Log a tick and show the running time in the sample project Every 3 seconds DebugMethods logs the time, and the screen shows the time updated every frame, to compare a recording's frames with its logcat panel. Co-Authored-By: Claude Opus 5.5 --- .../SampleProject1/Assets/DebugMethods.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/TestProjects/SampleProject1/Assets/DebugMethods.cs b/TestProjects/SampleProject1/Assets/DebugMethods.cs index 82beedc5..f2ee42ed 100644 --- a/TestProjects/SampleProject1/Assets/DebugMethods.cs +++ b/TestProjects/SampleProject1/Assets/DebugMethods.cs @@ -10,15 +10,31 @@ public class DebugMethods : MonoBehaviour // character and Enter starts a new line. string m_Typed = string.Empty; GUIStyle m_TypedStyle; + // Updated every frame, so the screen shows the time whatever the tick is doing. + float m_Time; // Start is called before the first frame update void Start() { TestDebug(); + StartCoroutine(Tick()); + } + + // A steady message to line up against a recording's frames. + IEnumerator Tick() + { + var wait = new WaitForSeconds(3); + while (true) + { + Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "Tick: {0:0.00}", Time.time); + yield return wait; + } } void Update() { + m_Time = Time.time; + var input = Input.inputString; if (string.IsNullOrEmpty(input)) return; @@ -61,7 +77,9 @@ void OnGUI() var margin = Screen.width * 0.05f; var rect = new Rect(margin, margin, Screen.width - 2 * margin, Screen.height - 2 * margin); - GUI.Label(rect, "Typed: " + m_Typed + "_", m_TypedStyle); + // The time running, to compare against the logcat panel. + var text = $"Time: {m_Time:0.00}\nTyped: {m_Typed}_"; + GUI.Label(rect, text, m_TypedStyle); } static string Escape(string input) From 6d65f301078ccdcb66a1c1cac047af656155b7de Mon Sep 17 00:00:00 2001 From: Tomas Date: Mon, 16 Nov 2026 14:47:19 +0200 Subject: [PATCH 10/10] Update the sample project to the current Editor ProjectVersion.txt and ProjectSettings.asset as saved by the Editor the project is now opened with. Co-Authored-By: Claude Opus 5.5 --- .../ProjectSettings/ProjectSettings.asset | 141 +++++++++++++----- .../ProjectSettings/ProjectVersion.txt | 4 +- 2 files changed, 108 insertions(+), 37 deletions(-) diff --git a/TestProjects/SampleProject1/ProjectSettings/ProjectSettings.asset b/TestProjects/SampleProject1/ProjectSettings/ProjectSettings.asset index 7b775fcb..92655921 100644 --- a/TestProjects/SampleProject1/ProjectSettings/ProjectSettings.asset +++ b/TestProjects/SampleProject1/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 23 + serializedVersion: 28 productGUID: 9e0d97b4e9f2b244ab561a1639bc49cd AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -48,14 +48,17 @@ PlayerSettings: defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 + unsupportedMSAAFallback: 0 + m_SpriteBatchMaxVertexCount: 65535 + m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 mipStripping: 0 numberOfMipsStripped: 0 + numberOfMipsStrippedPerMipmapLimitGroup: {} m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 iosUseCustomAppBackgroundBehavior: 0 - iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 allowedAutorotateToLandscapeRight: 1 @@ -67,24 +70,29 @@ PlayerSettings: androidStartInFullscreen: 1 androidRenderOutsideSafeArea: 1 androidUseSwappy: 0 + androidDisplayOptions: 1 androidBlitType: 0 - androidResizableWindow: 0 + androidResizeableActivity: 0 androidDefaultWindowWidth: 1920 androidDefaultWindowHeight: 1080 androidMinimumWindowWidth: 400 androidMinimumWindowHeight: 300 androidFullscreenMode: 1 + androidAutoRotationBehavior: 1 + androidPredictiveBackSupport: 1 + androidApplicationEntry: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 - captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 + audioSpatialExperience: 0 deferSystemGesturesMode: 0 hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 + dedicatedServerOptimizations: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 useFlipModelSwapchain: 1 @@ -92,6 +100,7 @@ PlayerSettings: useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 1 + meshDeformation: 2 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -119,21 +128,20 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 + switchGpuScratchPoolGranularity: 2097152 + switchAllowGpuScratchShrinking: 0 switchNVNMaxPublicTextureIDCount: 0 switchNVNMaxPublicSamplerIDCount: 0 - stadiaPresentMode: 0 - stadiaTargetFramerate: 0 + switchMaxWorkerMultiple: 8 + switchNVNGraphicsFirmwareMemory: 32 vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 vulkanEnablePreTransform: 0 vulkanEnableLateAcquireNextImage: 0 vulkanEnableCommandBufferRecycling: 1 - m_SupportedAspectRatios: - 4:3: 1 - 5:4: 1 - 16:10: 1 - 16:9: 1 - Others: 1 + loadStoreDebugModeEnabled: 0 + visionOSBundleVersion: 1.0 + tvOSBundleVersion: 1.0 bundleVersion: 0.1 preloadedAssets: [] metroInputSource: 0 @@ -146,23 +154,26 @@ PlayerSettings: isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 enableOpenGLProfilerGPURecorders: 1 + allowHDRDisplaySupport: 0 useHDRDisplay: 0 - D3DHDRBitDepth: 0 + hdrBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 + androidMinAspectRatio: 1 applicationIdentifier: Android: com.Unity.AndroidLogcatSample buildNumber: Standalone: 0 + VisionOS: 0 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 22 + AndroidMinSdkVersion: 23 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -172,15 +183,20 @@ PlayerSettings: ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 - APKExpansionFiles: 0 + androidSplitApplicationBinary: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 1 + strictShaderVariantMatching: 0 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 11.0 + iOSSimulatorArchitecture: 0 + iOSTargetOSVersionString: 13.0 tvOSSdkVersion: 0 + tvOSSimulatorArchitecture: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 11.0 + tvOSTargetOSVersionString: 13.0 + VisionOSSdkVersion: 0 + VisionOSTargetOSVersionString: 1.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -205,7 +221,6 @@ PlayerSettings: rgba: 0 iOSLaunchScreenFillPct: 100 iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: iOSLaunchScreeniPadType: 0 iOSLaunchScreeniPadImage: {fileID: 0} iOSLaunchScreeniPadBackgroundColor: @@ -213,7 +228,6 @@ PlayerSettings: rgba: 0 iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: iOSLaunchScreenCustomStoryboardPath: iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] @@ -223,13 +237,16 @@ PlayerSettings: iOSMetalForceHardShadows: 0 metalEditorSupport: 1 metalAPIValidation: 1 + metalCompileShaderBinary: 0 iOSRenderExtraFrameOnPause: 0 iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + VisionOSManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 + VisionOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 @@ -244,16 +261,21 @@ PlayerSettings: useCustomLauncherGradleManifest: 0 useCustomBaseGradleTemplate: 0 useCustomGradlePropertiesTemplate: 0 + useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 - AndroidTargetArchitectures: 1 - AndroidTargetDevices: 0 + AndroidTargetArchitectures: 2 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: '{inproject}: ' AndroidKeyaliasName: + AndroidEnableArmv9SecurityFeatures: 0 + AndroidEnableArm64MTE: 0 AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 + androidAppCategory: 3 + useAndroidAppCategory: 1 + androidAppCategoryOther: AndroidEnableTango: 0 androidEnableBanner: 1 androidUseLowAccuracyLocation: 0 @@ -263,12 +285,12 @@ PlayerSettings: height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 - chromeosInputEmulation: 1 - AndroidMinifyWithR8: 0 AndroidMinifyRelease: 0 AndroidMinifyDebug: 0 AndroidValidateAppBundleSize: 1 AndroidAppBundleSizeToValidate: 150 + AndroidReportGooglePlayAppDependencies: 1 + androidSymbolsSizeThreshold: 800 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: - m_BuildTarget: Android @@ -424,7 +446,7 @@ PlayerSettings: m_GraphicsJobMode: 0 m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer - m_APIs: 0b00000008000000 + m_APIs: 0b000000 m_Automatic: 0 - m_BuildTarget: iOSSupport m_APIs: 10000000 @@ -452,12 +474,18 @@ PlayerSettings: iPhone: 1 tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupHDRCubemapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetGroupLoadStoreDebugModeSettings: [] m_BuildTargetNormalMapEncoding: [] - m_BuildTargetDefaultTextureCompressionFormat: [] + m_BuildTargetDefaultTextureCompressionFormat: + - serializedVersion: 3 + m_BuildTarget: Android + m_Formats: 01000000 playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 + editorGfxJobOverride: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 enableCrashReportAPI: 0 @@ -465,6 +493,7 @@ PlayerSettings: locationUsageDescription: microphoneUsageDescription: bluetoothUsageDescription: + macOSTargetOSVersion: 11.0 switchNMETAOverride: switchNetLibKey: switchSocketMemoryPoolSize: 6144 @@ -472,10 +501,11 @@ PlayerSettings: switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 - switchUseGOLDLinker: 0 + switchEnableFileSystemTrace: 0 switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: + switchCompilerFlags: switchTitleNames_0: switchTitleNames_1: switchTitleNames_2: @@ -549,7 +579,6 @@ PlayerSettings: switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 switchStartupUserAccount: 0 - switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 switchApplicationErrorCodeCategory: @@ -591,6 +620,7 @@ PlayerSettings: switchNativeFsCacheSize: 32 switchIsHoldTypeHorizontal: 0 switchSupportedNpadCount: 8 + switchEnableTouchScreen: 1 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -601,13 +631,14 @@ PlayerSettings: switchSocketBufferEfficiency: 4 switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 + switchDisableHTCSPlayerConnection: 0 switchUseNewStyleFilepaths: 0 switchUseLegacyFmodPriorities: 1 switchUseMicroSleepForYield: 1 switchEnableRamDiskSupport: 0 switchMicroSleepForYieldTime: 25 switchRamDiskSpaceSize: 12 + switchUpgradedPlayerSettingsToNMETA: 0 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -691,6 +722,7 @@ PlayerSettings: webGLMemorySize: 256 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 + webGLShowDiagnostics: 0 webGLDataCaching: 1 webGLDebugSymbols: 0 webGLEmscriptenArgs: @@ -703,26 +735,54 @@ PlayerSettings: webGLLinkerTarget: 1 webGLThreadsSupport: 0 webGLDecompressionFallback: 0 + webGLInitialMemorySize: 32 + webGLMaximumMemorySize: 2048 + webGLMemoryGrowthMode: 2 + webGLMemoryLinearGrowthStep: 16 + webGLMemoryGeometricGrowthStep: 0.2 + webGLMemoryGeometricGrowthCap: 96 + webGLEnableWebGPU: 0 webGLPowerPreference: 2 + webGLWebAssemblyTable: 0 + webGLWebAssemblyBigInt: 0 + webGLCloseOnQuit: 0 + webWasm2023: 0 scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Android: 1 il2cppCompilerConfiguration: {} - managedStrippingLevel: {} + il2cppCodeGeneration: {} + il2cppStacktraceInformation: {} + managedStrippingLevel: + Android: 1 + EmbeddedLinux: 1 + GameCoreScarlett: 1 + GameCoreXboxOne: 1 + Kepler: 1 + Nintendo Switch: 1 + Nintendo Switch 2: 1 + PS4: 1 + PS5: 1 + QNX: 1 + VisionOS: 1 + WebGL: 1 + Windows Store Apps: 1 + XboxOne: 1 + iPhone: 1 + tvOS: 1 incrementalIl2cppBuild: {} suppressCommonWarnings: 1 allowUnsafeCode: 0 useDeterministicCompilation: 1 - enableRoslynAnalyzers: 1 - selectedPlatform: 2 additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 0 - assemblyVersionValidation: 1 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: Android: 6 + editorAssembliesCompatibilityLevel: 1 m_RenderingPath: 1 m_MobileRenderingPath: 1 metroPackageName: Template_3D @@ -747,6 +807,7 @@ PlayerSettings: metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} metroSplashScreenUseBackgroundColor: 0 + syncCapabilities: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} metroFTAName: @@ -794,7 +855,14 @@ PlayerSettings: luminVersion: m_VersionCode: 1 m_VersionName: + hmiPlayerDataPath: + hmiForceSRGBBlit: 1 + embeddedLinuxEnableGamepadInput: 0 + hmiCpuConfiguration: + hmiLogStartupTiming: 0 + qnxGraphicConfPath: apiCompatibilityLevel: 6 + captureStartupLogs: {} activeInputHandler: 0 windowsGamepadBackendHint: 0 cloudProjectId: e733115d-57cb-4cf1-a3ab-49a625ed264e @@ -804,6 +872,9 @@ PlayerSettings: organizationId: tomas1856 cloudEnabled: 0 legacyClampBlendShapeWeights: 0 - playerDataPath: - forceSRGBBlit: 1 + hmiLoadingImage: {fileID: 0} + platformRequiresReadableAssets: 0 virtualTexturingSupportEnabled: 0 + insecureHttpOption: 0 + androidVulkanDenyFilterList: [] + androidVulkanAllowFilterList: [] diff --git a/TestProjects/SampleProject1/ProjectSettings/ProjectVersion.txt b/TestProjects/SampleProject1/ProjectSettings/ProjectVersion.txt index f2af5208..eb36c7cb 100644 --- a/TestProjects/SampleProject1/ProjectSettings/ProjectVersion.txt +++ b/TestProjects/SampleProject1/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.0.72f1 -m_EditorVersionWithRevision: 6000.0.72f1 (cffd6ff00b65) +m_EditorVersion: 6000.0.85f1 +m_EditorVersionWithRevision: 6000.0.85f1 (ee7790f1426a)