-
Notifications
You must be signed in to change notification settings - Fork 108
[MBL-19580][Student][Teacher] File download logic update #3436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MBL-19580][Student][Teacher] File download logic update #3436
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Review Summary
This PR simplifies media URI handling by removing the RouteUtils.getMediaUri() function and its associated network HEAD request logic. The changes move responsibility for following redirects and determining media types into the download flow rather than pre-checking URLs.
Positive Changes
- Code simplification: Removes async complexity from multiple video player initialization flows, making the code easier to follow
- Reduced network calls: Eliminates unnecessary HEAD requests before video playback
- Better error handling: Moves DASH format detection into ExoPlayer's error handler with automatic .mpd retry
- Cleaner architecture: Consolidates download logic into
OpenMediaAsyncTaskLoader.downloadWithHeaders()
Issues Found
- Resource leak risk in
OpenMediaAsyncTaskLoader.kt:329- Error handling during file download could be more robust - State inconsistency in
OpenMediaAsyncTaskLoader.kt:197- Instance variables may be left inconsistent if download fails - Cache validation in
OpenMediaAsyncTaskLoader.kt:316- Cached files are only checked for existence/size, not corruption - Retry logic in
ExoPlayerHelper.kt:180- Player state may be inconsistent if second retry also fails - Missing logging in
ExoPlayerHelper.kt:175- New retry mechanism should have logging for debugging - URL detection limitation in
BaseRouterActivity.kt:319- Simple extension check won't handle redirects or obfuscated URLs - Missing newline at end of
OpenMediaAsyncTaskLoader.kt:469
Architecture & Performance Considerations
Performance: This change should improve performance by eliminating HEAD requests. However, it shifts complexity to the download phase where errors are discovered later.
Backwards compatibility: The removal of redirect-following in shouldOpenInternally() may cause some videos to not open internally that previously would have. URLs that redirect to .mpd/.m3u8/.mp4 files will no longer be detected.
Testing needs: The ExoPlayer retry logic and new download flow would benefit from additional testing, especially around edge cases like network failures, corrupted caches, and DASH format detection.
Overall Assessment
This is a good refactoring that simplifies the codebase and removes unnecessary network overhead. The inline comments highlight areas where additional error handling or validation could make the implementation more robust. The changes follow Kotlin best practices and maintain consistency with the existing codebase architecture.
libs/pandautils/src/main/java/com/instructure/pandautils/loaders/OpenMediaAsyncTaskLoader.kt
Show resolved
Hide resolved
libs/pandautils/src/main/java/com/instructure/pandautils/loaders/OpenMediaAsyncTaskLoader.kt
Show resolved
Hide resolved
libs/pandautils/src/main/java/com/instructure/pandautils/loaders/OpenMediaAsyncTaskLoader.kt
Show resolved
Hide resolved
libs/pandautils/src/main/java/com/instructure/pandautils/utils/ExoPlayerHelper.kt
Show resolved
Hide resolved
libs/pandautils/src/main/java/com/instructure/pandautils/utils/ExoPlayerHelper.kt
Show resolved
Hide resolved
apps/student/src/main/java/com/instructure/student/activity/BaseRouterActivity.kt
Show resolved
Hide resolved
libs/pandautils/src/main/java/com/instructure/pandautils/loaders/OpenMediaAsyncTaskLoader.kt
Show resolved
Hide resolved
🧪 Unit Test Results✅ 📱 Student App
✅ 📱 Teacher App
✅ 🌅 Horizon
✅ 📦 Submodules
📊 Summary
Last updated: Wed, 10 Dec 2025 09:01:50 GMT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Student/Teacher: The mp4 files among the inbox attachments still don’t play, I’m getting the same error as before.
- Student/Teacher: The mp4 files in announcement and discussion attachments still aren’t working, I’m getting the same error as before.
- Teacher: The newly submitted File-upload submissions still can’t play mp3 or mp4 files, I get a “This media format is not supported” error. This also applies to comment attachments as well. (See attached screenshot.)
adamNagy56
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA +1
e04fa9a
into
release/student-8.4.1-284

Test plan:
refs: MBL-19580
affects: Student, Teacher
release note: none
Checklist