Skip to content

Conversation

@tamaskozmer
Copy link
Contributor

No description provided.

tamaskozmer and others added 2 commits December 9, 2025 17:35
refs: MBL-19580
affects: Student, Teacher
release note: none
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

This PR removes the RouteUtils.getMediaUri() functionality and refactors media handling to simplify video playback. While the intention to streamline the code is good, there are several concerns that need to be addressed:

Critical Issues

  • Bug in BaseRouterActivity.kt:319 - Removed RouteUtils.getMediaUri() call means the code now checks file extensions on redirect URLs instead of the actual media URLs. Canvas media URLs like /media_objects_iframe/123?type=video won't have .mpd, .m3u8, or .mp4 extensions, causing media files to incorrectly not open internally.

  • Performance issue in OpenMediaAsyncTaskLoader.kt:285-325 - The new downloadWithHeaders() method establishes HTTP connection and prepares to download the response body BEFORE checking if the file is already cached. This wastes bandwidth and time for cached files. The original implementation checked cache first, then only downloaded if needed.

  • Logic issue in OpenMediaAsyncTaskLoader.kt:158 - For remote URLs, the intent data is set to Uri.parse(url) (the raw URL) before downloading. This may cause the app to try opening the URL directly instead of waiting for the local file download to complete.

Positive Changes

ExoPlayerHelper.kt automatic retry - The new logic to automatically retry with .mpd extension when encountering UnrecognizedInputFormatException is a clever workaround for DASH videos without proper extensions.

Code simplification - Removing the coroutine-based RouteUtils.getMediaUri() simplifies the async handling in multiple places.

Unified download logic - The new downloadWithHeaders() method consolidates header parsing and downloading in one place.

Recommendations

  1. Keep URL resolution logic: The RouteUtils.getMediaUri() functionality was solving a real problem - Canvas redirects don't have file extensions in the URL. Either keep this function or implement proper URL resolution before checking extensions.

  2. Fix cache checking: Move file existence check BEFORE making network requests. Consider using HEAD requests to get headers without downloading when you need metadata for cached files.

  3. Test thoroughly: This changes core media handling across all three apps. Test with:

    • Canvas media redirects
    • Direct media URLs
    • Cached vs non-cached files
    • Different media types (.mpd, .m3u8, .mp4)
    • DASH videos with and without proper extensions

Minor Issues

  • Missing newline at end of OpenMediaAsyncTaskLoader.kt (line 469)
  • Consider adding debug logging when ExoPlayer retries with .mpd extension

Test Coverage

The removal of tests in RouteUtilsTest.kt is concerning - those tests were validating important redirect and content-type handling logic. Consider adding equivalent tests for the new implementation to prevent regressions.

Copy link
Contributor

@adamNagy56 adamNagy56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA +1

Copy link
Contributor

@kdeakinstructure kdeakinstructure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA 👍

@tamaskozmer tamaskozmer merged commit 7994521 into release/teacher Dec 11, 2025
6 checks passed
@tamaskozmer tamaskozmer deleted the release/teacher-2.3.1-86 branch December 11, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants