Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.mobile.android-logcat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed Tools->Open Terminal not opening a window on Windows Editor when running on CoreCLR.
- Added a Commands window, accessible via the Tools menu in the Android Logcat window. It lets you save, organize, search and run adb commands which don't have a dedicated UI in this package, such as package management, permissions, dumpsys, settings and Meta Quest properties. Commands run asynchronously so the Editor stays responsive, support `<placeholder>` substitution with per-token examples and suggestions, and can be imported and exported as JSON. Catalog commands display a description of what they do when you hover over them. Edit Mode supports selecting several commands and deleting them in one step.
- Fixed log lines with an empty message not being parsed. They appeared as unformatted text with no tag, process ID or priority, and were hidden when filtering by tag.
- Fixed auto scrolling not turning back on after scrolling to the last message when Scroll is set to Auto. It happened only at certain Logcat window heights. (UUM-162014)

## [1.4.7] - 2025-12-12
### Fixes & Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ private void DoDebuggingGUI()
if (cannotKeepUp)
message += " (CAN'T KEEP UP!!!!)";
GUILayout.Label(message, style);
GUILayout.Label($"Window: {position.width:F0}x{position.height:F0}");
Comment thread
todi1856 marked this conversation as resolved.
Resolved
EditorGUILayout.EndHorizontal();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ public void Reset()
PerformScrollWhileInAuto = true;
}
}

// Extra message count ensures that there's an empty space below when we scrolling all the way down
// This way it's easier to see that there's no more messages
internal const int kExtraMessageCount = 5;

/// <summary>
/// Whether the last log entry is visible for the given scroll position.
/// Compared in pixels, since comparing rounded item counts fails at certain window heights,
/// when the fractional part of visible rows is bigger than the horizontal scrollbar height.
/// Note: visibleHeight includes horizontal scrollbar, so the entry might be partially hidden behind the scrollbar.
/// </summary>
internal static bool IsLastEntryVisible(float scrollY, float visibleHeight, int entryCount, int rowHeight)
{
return scrollY + visibleHeight >= rowHeight * entryCount;
}

internal enum Column
{
Icon,
Expand Down Expand Up @@ -379,9 +395,6 @@ private bool DoGUIEntries()
var visibleWindowRect = GUILayoutUtility.GetRect(GUIContent.none, AndroidLogcatStyles.priorityDefaultStyle, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
var totalWindowRect = visibleWindowRect;
var maxVisibleItems = (int)(visibleWindowRect.height / AndroidLogcatStyles.kLogEntryFixedHeight);
// Extra message count ensures that there's an empty space below when we scrolling all the way down
// This way it's easier to see that there's no more messages
const int kExtraMessageCount = 5;
totalWindowRect.height = AndroidLogcatStyles.kLogEntryFixedHeight * (FilteredEntries.Count + kExtraMessageCount);
totalWindowRect.width = Mathf.Max(totalWindowRect.width, m_MaxLogEntryWidth);

Expand Down Expand Up @@ -429,7 +442,7 @@ private bool DoGUIEntries()
if (m_Runtime.UserSettings.AutoScroll == AutoScroll.Auto)
{
if (scrollChanged || (e.type == EventType.ScrollWheel && e.delta.y > 0.0f))
m_ScrollData.PerformScrollWhileInAuto = startItem + maxVisibleItems - kExtraMessageCount >= FilteredEntries.Count;
m_ScrollData.PerformScrollWhileInAuto = IsLastEntryVisible(m_ScrollPosition.y, visibleWindowRect.height, FilteredEntries.Count, AndroidLogcatStyles.kLogEntryFixedHeight);
else if (e.type == EventType.ScrollWheel && e.delta.y < 0.0f)
m_ScrollData.PerformScrollWhileInAuto = false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using NUnit.Framework;
using Unity.Android.Logcat;

class AndroidLogcatAutoScrollTests
{
const int kEntryCount = 1000;

// Mirrors GUI.BeginScrollView: the content height includes the extra empty rows below the last entry,
// and the viewport is reduced by the always visible horizontal scrollbar
static float GetMaxScrollY(float visibleHeight, int entryCount, int rowHeight, float horizontalScrollbarHeight)
{
var totalHeight = rowHeight * (entryCount + AndroidLogcatConsoleWindow.kExtraMessageCount);
var viewportHeight = visibleHeight - horizontalScrollbarHeight;
return totalHeight - viewportHeight;
}

[Test]
public void LastEntryIsVisibleWhenScrolledToBottom_ForAnyWindowHeight(
[Values(12, 16, 20, 25, 30)] int rowHeight,
[Values(0.0f, 13.0f, 15.0f)] float horizontalScrollbarHeight)
{
// Previously comparing rounded item counts failed when the fractional part of visible rows
// was bigger than horizontal scrollbar height, for ex., 350px height with 16px rows
for (float visibleHeight = 100.0f; visibleHeight <= 1500.0f; visibleHeight += 0.5f)
{
var maxScrollY = GetMaxScrollY(visibleHeight, kEntryCount, rowHeight, horizontalScrollbarHeight);
Assert.IsTrue(AndroidLogcatConsoleWindow.IsLastEntryVisible(maxScrollY, visibleHeight, kEntryCount, rowHeight),
$"Last entry should be visible at bottom, visible height {visibleHeight}, row height {rowHeight}, scrollbar height {horizontalScrollbarHeight}");
}
}

[Test]
public void LastEntryIsNotVisibleWhenScrolledAboveIt()
{
const int rowHeight = 16;
const float visibleHeight = 350.0f;
var lastEntryBottom = rowHeight * kEntryCount;

Assert.IsFalse(AndroidLogcatConsoleWindow.IsLastEntryVisible(0.0f, visibleHeight, kEntryCount, rowHeight));
Assert.IsFalse(AndroidLogcatConsoleWindow.IsLastEntryVisible(lastEntryBottom - visibleHeight - 1.0f, visibleHeight, kEntryCount, rowHeight));
Assert.IsTrue(AndroidLogcatConsoleWindow.IsLastEntryVisible(lastEntryBottom - visibleHeight, visibleHeight, kEntryCount, rowHeight));
}

[Test]
public void LastEntryIsVisibleWhenAllEntriesFit()
{
const int rowHeight = 16;
Assert.IsTrue(AndroidLogcatConsoleWindow.IsLastEntryVisible(0.0f, 350.0f, 10, rowHeight));
Assert.IsTrue(AndroidLogcatConsoleWindow.IsLastEntryVisible(0.0f, 350.0f, 0, rowHeight));
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.