Skip to content

[C4GT Bounty] Fix: Critical Bugs (Black Screen, Video Timer, Cloud Sync, PDF Crash, Admin Nav)#8

Open
aviralsaxena16 wants to merge 10 commits intoPlanetRead:mainfrom
aviralsaxena16:Fixing-the-bugs
Open

[C4GT Bounty] Fix: Critical Bugs (Black Screen, Video Timer, Cloud Sync, PDF Crash, Admin Nav)#8
aviralsaxena16 wants to merge 10 commits intoPlanetRead:mainfrom
aviralsaxena16:Fixing-the-bugs

Conversation

@aviralsaxena16
Copy link
Copy Markdown

@aviralsaxena16 aviralsaxena16 commented Oct 24, 2025

Hello @keerthiseelan-planetread,

This PR is submitted for the **C4GT Bounty: PlanetRead Video Watch Timer Issue #7 **.

After cloning the repository, setting up the full local environment, and testing on an Android emulator, I identified and fixed several critical bugs—including all the major issues listed on the bounty ticket and other unlisted blockers I discovered.

This PR serves as my "proof of work" and demonstrates my ability to debug and solve issues across the entire stack (React Native, native Android, and backend services).


1. The "Black Screen" Crash: SOLVED ⬛

  • Bug: The app crashed to a black screen if the user navigated back (using the on-screen or hardware back button) while the video player (video/[id].tsx) was in the middle of an async operation.
  • Fix: I implemented an isMountedRef guard in the video/[id].tsx component. This ref prevents setState calls from being executed on an unmounted component, which was the root cause of the crash.
image

2. Incorrect Video Watch Time: SOLVED ⏱️

  • Bug: Video watch time was calculated incorrectly, especially after the video finished or the user navigated away.
  • Fix: I audited and refactored the time-tracking logic in app/video/[id].tsx. The returnBackToHome function and the statusChange listener now ensure that totalWatchTimeRef is always updated with the final elapsed time before the component unmounts or the player stops, guaranteeing accurate time capture.

3. The "Cloud Sync" Errors: SOLVED ☁️

The app's data-syncing feature was entirely broken due to multiple issues. I debugged and fixed all of them by setting up a local Supabase instance.

  • Bug 1: Incorrect Table Name: Error: Could not find the table 'public.user'.
    • Fix: Corrected the table name reference in components/SyncToCloud.tsx from user to the correct users.
  • Bug 2: Missing Primary Key Data: Error: null value in column "id" of relation "video_analytics".
    • Fix: The syncUsers function was not including the required id from the local analytics table when building the payload for Supabase. Added id: analytics.id to the data mapping, resolving the constraint violation.
  • Integration Note: Confirmed sync requires the Supabase users.id and video_analytics.user_id columns to accept text data type, matching the app's local ID format.
Screenshot 2025-10-24 101349

Result: With these code fixes and a correctly configured backend, cloud sync now runs successfully. ✅


4. The PDF Loading Crash: SOLVED 📄

  • Bug: Opening any PDF crashed the app with a native Android error: ReactNativeBlobUtil request error... Use of own trust manager...
  • Fix: Diagnosed as a native networking bug. Fixed by editing android/app/build.gradle and forcing a stable version of the okhttp library: implementation("com.squareup.okhttp3:okhttp:4.9.3").

5. The Admin Login Navigation Bug: SOLVED 🔒

  • Bug: On the home screen, tapping the "Billion Readers" bird icon did nothing.
  • Fix: Inspected app/(tabs)/index.tsx and changed the incorrect onLongPress trigger on the TouchableOpacity to a simple onPress, fixing navigation to /login.
Screenshot 2025-10-24 035806

🎥 Video Proof of All Fixes

Here is a video from my emulator demonstrating all the fixes working correctly:

  1. Successful PDF loading (English & Punjabi).
  2. Navigating back from the video player without crashing.
  3. Tapping the bird icon to instantly navigate to the admin login.
  4. Successfully logging into the admin dashboard.
  5. Successful Cloud Sync confirmed via terminal logs on app start.
  6. Correct Watch Time Calculation shown in terminal logs after watching a video.

Watch the Full Demo Video (Google Drive) 🎬


I am confident I can successfully implement the remaining features outlined in the bounty. Thank you for your consideration.

@aviralsaxena16
Copy link
Copy Markdown
Author

Hi @keerthiseelan-planetread, just checking in on this PR and my proposal. Any updates on the review timeline? I would love to contribute to this

Thanks!

@keerthiseelan-planetread
Copy link
Copy Markdown

keerthiseelan-planetread commented Oct 31, 2025

Hi @aviralsaxena16 I'm working the evaluation process, probably on Monday we can connect and my mail id is keerthiseelan@planetread.org

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.

2 participants