Merged
Conversation
Introduces a new `baselineprofile` module to generate and apply Baseline Profiles, aiming to improve application startup performance. - Adds the `androidx.baselineprofile` Gradle plugin and a new `:baselineprofile` module. - Includes `BaselineProfileGenerator.kt` to define the critical user journey for profile collection, focusing on app startup. - Adds `StartupBenchmarks.kt` to measure and verify the effectiveness of the generated profiles by comparing startup times with and without profile compilation. - Enables the Gradle configuration cache via `org.gradle.configuration-cache=true` in `gradle.properties` for faster builds. - Adds `profileinstaller` dependency to the main app module to enable profile usage.
Introduces a `is_benchmark` intent flag to streamline app startup during Baseline Profile generation, bypassing setup screens and permission dialogs for a more stable and direct launch to the main screen. - **MainActivity.kt**: - Reads a new `is_benchmark` boolean extra from the intent. - Skips the `SetupScreen` if `is_benchmark` is true. - Prevents the "All Files Access" dialog from appearing during benchmark runs. - **BaselineProfileGenerator.kt**: - Simplifies the generation script to perform only a cold start and a brief wait, removing complex UI interactions (tab navigation, scrolling, sheet opening) that caused instability. - Launches the app with the `--ez is_benchmark true` flag to ensure a direct path to the `HomeScreen`. - Grants `MANAGE_EXTERNAL_STORAGE` and `POST_NOTIFICATIONS` permissions via shell commands before the run to avoid system dialogs. - **HomeScreen.kt**: - Adds `ReportDrawnWhen` to signal when the screen is fully drawn, using the presence of songs or the `is_benchmark` flag as a trigger. - Suppresses the app rebrand dialog when in benchmark mode. - **Build & Dependencies**: - Adds a new `benchmark` build type in `app/build.gradle.kts` that inherits from `release` but is debuggable. - Updates `benchmark-macro-junit4` and `baselineprofile` libraries to version `1.3.3`. - Includes the `baselineprofile` module in the Gradle project settings.
…t frame detection checks that cause timeouts on some devices.
…n Xiaomi devices during Baseline Profile generation.
…click retry logic.
…ypass profile flush errors.
…adle plugin detects the profile.
…o capture complex animations and heavy UI components.
…finding Play/Pause buttons.
…o ensure playback starts in BaselineProfileGenerator.
…re UnifiedPlayerSheet profiling.
Improves the reliability and robustness of the `BaselineProfileGenerator` and `StartupBenchmarks` to handle inconsistencies across different devices and languages.
- **`gradle.properties`**:
- Adds `androidx.benchmark.suppressErrors=EMULATOR,LOW-BATTERY,THERMAL` to prevent benchmark failures in non-ideal CI environments.
- **`StartupBenchmarks.kt`**:
- Switches to `BaselineProfileMode.UseIfAvailable` from `Require` to prevent failures on devices where profiles aren't strictly enforced (e.g., Samsung/OneUI).
- Simplifies the benchmark setup by hardcoding the package name and reducing iterations to 5 for faster validation.
- Removes the complex setup block in favor of a straightforward `pressHome()` and `startActivityAndWait()`.
- **`BaselineProfileGenerator.kt`**:
- **Internationalization**: Replaces hardcoded English UI strings with regex patterns (`Pattern.compile`) to match both English and Spanish text (e.g., "Queue|Cola", "Library|Biblioteca").
- **Error Handling**: Implements a robust rescue mechanism for profile generation failures. If a `flush profiles` error occurs, it now attempts to copy the generated profile to multiple common storage locations (`/Download`, `/sdcard`, and app-specific external storage) and logs `adb pull` commands for easy manual retrieval.
- **UI Interaction**:
- Simplifies and stabilizes UI interaction logic, making clicks more resilient and removing brittle waits.
- Improves navigation between tabs and interaction with the player sheet.
- Increases `maxIterations` from 1 to 3 for a more comprehensive profile.
…ion-8630355174009459809 Fix baseline profile generation 8630355174009459809
Enhances the BaselineProfileGenerator to cover more critical user flows and reduce flakiness. - Added explicit list scrolling scenarios (Library, Home, Search) with both scroll and fling gestures to capture list rendering paths. - Added deep navigation to detail screens (e.g., Album Detail) from the library. - Implemented a robust flow for `UnifiedPlayerSheet` including expansion, carousel interaction, and queue toggling. - Improved reliability with `wait(Until...)` and granular try-catch blocks. - Added missing imports and restored the `is_benchmark` intent extra to ensure consistent test behavior.
Enhances the BaselineProfileGenerator to cover more critical user flows and reduce flakiness. - Added explicit list scrolling scenarios (Library, Home, Search) with both scroll and fling gestures to capture list rendering paths. - Added deep navigation to detail screens (e.g., Album Detail) from the library. - Implemented a robust flow for `UnifiedPlayerSheet` including expansion, carousel interaction, and queue toggling. - Improved reliability with `wait(Until...)` and granular try-catch blocks. - Added missing imports and restored the `is_benchmark` intent extra to ensure consistent test behavior. - Implemented `waitForAppLoading` to handle the initial "Preparing your library..." overlay. - Added explicit `setupPermissions` granting `READ_MEDIA_AUDIO` and other critical permissions. - Switched to `startActivityAndWait` with a manual benchmark intent and added `waitForIdle` to improve startup stability. - Added `runLibrarySubTabsFlow` to iterate and scroll through "Songs", "Albums", and "Artists" tabs explicitly.
Enhances the BaselineProfileGenerator to cover more critical user flows and reduce flakiness. - Added explicit list scrolling scenarios (Library, Home, Search) with both scroll and fling gestures to capture list rendering paths. - Added deep navigation to detail screens (e.g., Album Detail) from the library. - Implemented a robust flow for `UnifiedPlayerSheet` including expansion, carousel interaction, and queue toggling. - Improved reliability with `wait(Until...)` and granular try-catch blocks. - Added missing imports and restored the `is_benchmark` intent extra to ensure consistent test behavior. - Implemented `waitForAppLoading` to handle the initial "Preparing your library..." overlay. - Added explicit `setupPermissions` granting `READ_MEDIA_AUDIO` and other critical permissions. - Switched to `startActivityAndWait` with a manual benchmark intent and added `waitForIdle` to improve startup stability. - Added `runLibrarySubTabsFlow` to iterate and scroll through "Songs", "Albums", and "Artists" tabs explicitly. - Implemented `ensurePlayerCollapsed` to detect and dismiss the expanded player if it obscures navigation. - Added `runSettingsFlow` to navigate to and scroll through the Settings screen. - Enhanced UI selectors to support both English and Spanish locales and fall back between `text` and `contentDescription`.
Enhances the BaselineProfileGenerator to be more robust and observable.
- Replaced `startActivityAndWait` with `device.executeShellCommand("am start ...")` to resolve "Unable to confirm activity launch completion" crashes on some devices.
- Added explicit `device.waitForIdle(2000)` pauses and detailed `Log.d` tracing to allow visual confirmation of test progress.
- Implemented `ensurePlayerCollapsed` to guarantee the UI is in a navigable state before running tab interactions.
- Added `runSettingsFlow` to profile the Settings screen.
- Improved reliability of `runTabsAndScrollingFlow` and `runUnifiedPlayerSheetFlow` with better selectors and logging.
- Retained waiting logic for "Preparing your library..." overlay.
Enhances the BaselineProfileGenerator to be more robust and observable.
- Replaced `startActivityAndWait` with `device.executeShellCommand("am start ...")` to resolve "Unable to confirm activity launch completion" crashes on some devices.
- Added explicit `device.waitForIdle(2000)` pauses and detailed `Log.d` tracing to allow visual confirmation of test progress.
- Implemented `ensurePlayerCollapsed` to guarantee the UI is in a navigable state before running tab interactions.
- Added `runSettingsFlow` to profile the Settings screen.
- Improved reliability of `runTabsAndScrollingFlow` and `runUnifiedPlayerSheetFlow` with better selectors and logging.
- Retained waiting logic for "Preparing your library..." overlay.
- Added Home specific scroll flow and Library Pager lateral swipe flow.
- Added margin to scroll gestures to avoid pulling notification shade.
- Added interactions with Player buttons and Slider.
Enhances the BaselineProfileGenerator to be more robust and observable.
- Replaced `startActivityAndWait` with `device.executeShellCommand("am start ...")` to resolve "Unable to confirm activity launch completion" crashes on some devices.
- Added explicit `device.waitForIdle(2000)` pauses and detailed `Log.d` tracing to allow visual confirmation of test progress.
- Implemented `ensurePlayerCollapsed` to guarantee the UI is in a navigable state before running tab interactions.
- Added `runSettingsFlow` to profile the Settings screen.
- Improved reliability of `runTabsAndScrollingFlow` and `runUnifiedPlayerSheetFlow` with better selectors and logging.
- Retained waiting logic for "Preparing your library..." overlay.
- Added Home specific scroll flow and Library Pager lateral swipe flow.
- Added margin to scroll gestures to avoid pulling notification shade.
- Added interactions with Player buttons and Slider.
- Reordered steps to match user request: Home -> Settings -> Main Tabs -> Library Sub-tabs -> Player.
Enhances the BaselineProfileGenerator to be more robust and observable.
- Replaced `startActivityAndWait` with `device.executeShellCommand("am start ...")` to resolve "Unable to confirm activity launch completion" crashes on some devices.
- Added explicit `device.waitForIdle(2000)` pauses and detailed `Log.d` tracing to allow visual confirmation of test progress.
- Implemented `ensurePlayerCollapsed` to guarantee the UI is in a navigable state before running tab interactions.
- Added `runSettingsFlow` to profile the Settings screen.
- Improved reliability of `runTabsAndScrollingFlow` and `runUnifiedPlayerSheetFlow` with better selectors and logging.
- Retained waiting logic for "Preparing your library..." overlay.
- Added Home specific scroll flow and Library Pager lateral swipe flow.
- Added margin to scroll gestures to avoid pulling notification shade.
- Added interactions with Player buttons and Slider.
- Reordered steps to match user request: Home -> Settings -> Main Tabs -> Library Sub-tabs -> Player.
- Added critical `waitForTab` gatekeeper check to prevent premature test execution before the app is fully loaded.
- Refined UI selectors to match hardcoded strings like "Settings" and provide robust fallbacks for localized navigation tabs.
- Added UI fallback for permission granting.
- Updated `CustomNavigationBarItem.kt` to accept a `contentDescription` and set it on the root `Column` semantics, ensuring UI Automator can locate the tab. - Updated `PlayerInternalNavigationBar.kt` to pass `item.label` as the `contentDescription`. - Refined `BaselineProfileGenerator.kt` to prioritize `By.desc` for tab selection, while retaining `By.text` as a fallback. - Added explicit waits and checks to ensure navigation scenarios (Home, Settings, Library) run correctly before interacting with the player. - Optimized `runLibraryPagerSwipeFlow` with slower swipes for better pager detection. - Adjusted `safeScrollContent` margin to avoid notification shade interactions.
- Updated `BaselineProfileGenerator.kt`: Optimized `waitForTab` to prioritize checking `By.desc` first, significantly reducing wait times for accessible navigation tabs. - Updated `CustomNavigationBarItem.kt`: Refined the semantics assignment to be conditional (`if (contentDescription != null)`). This prevents overriding the default merged text semantics with an empty string when no description is provided, ensuring better accessibility compliance. - Verified that the generator executes the full sequence (Home -> Settings -> Tabs -> Library -> Player) robustly.
…ompose stability config Overhauls the Baseline Profile generator for increased reliability and introduces a Compose stability configuration to improve runtime performance by reducing recompositions. ### `BaselineProfileGenerator.kt` - Rewrites the entire generation flow to be more linear and robust, using `Thread.sleep` instead of `waitForIdle` for more predictable timing. - Structures the process into discrete, named steps (`runStep`) for improved logging and debugging (e.g., Settings, Force Play, Main Tabs, Library Pager, Player Sheet). - Simplifies UI interactions, replacing complex selectors and waits with more direct actions like coordinate-based clicks and "blind" swipes. - Implements a more resilient permission setup (`setupResilientPermissions`) and a simplified onboarding handler. - Adds a new "Force Play" step to ensure a song is playing, making the player sheet interaction more reliable. - Improves the recovery mechanism (`recoverBaselineProfile`) to manually dump profiles and copy the file upon failure. ### Compose Stability (`app/build.gradle.kts`, `app/compose_stability.conf`) - Adds a `compose_stability.conf` file to explicitly mark frequently used data models and UI state classes (e.g., `Song`, `Album`, `PlayerUiState`) as stable. - Configures the Kotlin compiler in `app/build.gradle.kts` to use this stability file, enabling the Compose compiler to more effectively skip recompositions when underlying data has not changed.
…s-13161532055907276109 Improve Baseline Profile with enhanced scrolling and player scenarios
Extended the Baseline Profile generation circuit to include more comprehensive user interactions: - HomeScreen: Added scroll to bottom, and navigation to 'Daily Mix' and 'Stats' screens. - SearchScreen: Replaced generic click with navigation to 'Unknown' Genre detail screen. - LibraryScreen: Added 3-dot menu interaction (expand and scroll SongInfoBottomSheet) before playing a song. - UnifiedPlayerSheet: Added horizontal carousel swipes, WavyMusicSlider interaction, media button taps, and QueueBottomSheet opening/scrolling. - Added helper functions `scrollToListBottom` and `scrollToTop` for robust navigation.
Refined the interaction logic in `BaselineProfileGenerator` to prevent app crashes and `DeadObjectException` during profile generation. - Updated `scrollToListBottom` and `scrollToTop` to use safer swipe margins (0.25-0.75) and slower speeds (45 steps) to avoid conflicts with system navigation and ensure smoother UI updates. - Replaced immediate `findObject` calls with `device.wait(Until.findObject(...), timeout)` for critical UI elements like 'Daily Mix', 'Stats', 'More options', and Genre cards to handle UI loading delays robustly. - Added null checks and logging for safer execution of interaction steps.
Resolved a critical stability issue in `BaselineProfileGenerator` where `blindScroll` (UP then DOWN swipe) was inadvertently triggering the 'swipe-to-dismiss' gesture on `SongInfoBottomSheet` and `QueueBottomSheet`. This caused the subsequent `device.pressBack()` call to exit the application instead of just closing the sheet, leading to test failures and `DeadObjectException`. Changes: - Introduced `scrollBottomSheetContent()` helper that performs a single UP swipe to scroll content without risking dismissal. - Updated `Library Interaction` and `Unified Player Sheet` steps to use this safe scrolling method. - Added explicit waits (`Thread.sleep`) after sheet interactions to ensure UI stability before proceeding. - Added a safety wait before the 'Force Play' click to guarantee the list is interactive.
Resolved critical stability issues in `BaselineProfileGenerator` that caused the app to close unexpectedly during `WavyMusicSlider` interaction and `QueueBottomSheet` opening. Changes: - **Wavy Slider Y-coordinate:** Adjusted from `0.80` to `0.72` to avoid interacting with system navigation bars or bottom controls that might trigger app switching/back actions. - **Queue Fling:** Changed the start Y coordinate from `displayHeight - 50` to `displayHeight * 0.92`. The previous value was too close to the edge, triggering the system 'Home' gesture on modern Android versions. - **Queue Scrolling:** Replaced single scroll with a repeated `scrollBottomSheetContent()` call to ensure the queue is scrolled "significantly" as requested, without triggering dismissal. - **Safety:** Added waits between actions to allow UI animations to settle.
Resolved issues where the `UnifiedPlayerSheet` was collapsing instead of opening the Queue, and the `WavyMusicSlider` interaction was failing. Changes: - **Queue Opening:** Replaced the unreliable fling gesture with a direct click on the "Song options" (Queue) button in the TopBar. Added a regex pattern `.*(Song options|Opciones|Queue|Cola).*` to robustly identify this button across locales. - **Slider Interaction:** Implemented dynamic coordinate calculation for the `WavyMusicSlider` swipe. The swipe Y-coordinate is now derived from the Play/Pause button's position (`playButton.visibleBounds.top - 12% screen height`), ensuring the gesture correctly targets the slider area relative to the controls on various screen sizes. - **Safety:** Maintained explicit waits and null checks to ensure UI stability.
Resolved stability issues in the extended player flow: - **Queue Opening:** Replaced the button click with a robust "Fling Up" gesture to open the Queue BottomSheet, as explicitly requested. Added verification for the "Next Up" header to ensure the sheet is open before scrolling. - **Play/Pause Stability:** Fixed a crash caused by reusing a stale `UiObject2` reference for the Play/Pause button. The button is now re-found before the second click to handle the icon/state change safely. - **Error Logging:** Improved exception logging to print the full exception string, preventing unhelpful "null" error messages. These changes ensure the Baseline Profile Generator completes the full user journey without crashing or skipping steps.
Improves the reliability and clarity of the `BaselineProfileGenerator` script. - **Profile Recovery:** - Standardizes the output path for the generated profile to `/sdcard/Android/media/com.theveloper.pixelplay.baselineprofile/baseline-prof.txt`, ensuring consistent write permissions. - Adds logging and a 5-second delay after the `killall` command to allow more time for the profile to be written to disk before copying. - **Generator Script:** - Cleans up the script by removing redundant comments and unnecessary `Log.w` calls for non-critical path failures (e.g., if the "Stats" element isn't found). - Simplifies comments in the player UI and queue interaction steps for better readability. - Adds a title to the "Home Screen Extended Flow" section to clarify that it covers "Daily Mix & Stats".
…rator-8173872469908419694 Update BaselineProfileGenerator with extended interaction flows
Improves the reliability and clarity of the `BaselineProfileGenerator` script. - **Profile Recovery:** - Standardizes the output path for the generated profile to `/sdcard/Android/media/com.theveloper.pixelplay.baselineprofile/baseline-prof.txt`, ensuring consistent write permissions. - Adds logging and a 5-second delay after the `killall` command to allow more time for the profile to be written to disk before copying. - **Generator Script:** - Cleans up the script by removing redundant comments and unnecessary `Log.w` calls for non-critical path failures (e.g., if the "Stats" element isn't found). - Simplifies comments in the player UI and queue interaction steps for better readability. - Adds a title to the "Home Screen Extended Flow" section to clarify that it covers "Daily Mix & Stats".
…rator-8173872469908419694 Refactor: Improve Baseline Profile generation and recovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.