Skip to content

fix: prevent video corruption from rapid hide/unhide clicks#986

Open
Ahmed-Hekal-01 wants to merge 4 commits intoFossifyOrg:mainfrom
Ahmed-Hekal-01:bugfix
Open

fix: prevent video corruption from rapid hide/unhide clicks#986
Ahmed-Hekal-01 wants to merge 4 commits intoFossifyOrg:mainfrom
Ahmed-Hekal-01:bugfix

Conversation

@Ahmed-Hekal-01
Copy link

Fixes critical race condition when clicking hide button 2 times quickly.

Changes:

  • Add mIsTogglingVisibility flag to track ongoing visibility toggle operations
  • Check flag in click listener to prevent concurrent operations
  • Clear flag in callback when operation completes

This ensures only one hide/unhide operation runs at a time, preventing the race condition that corrupted video files.

Tested on Samsung A24, Android 16.

Type of change(s)

  • Bug fix
  • Feature / enhancement
  • Infrastructure / tooling (CI, build, deps, tests)
  • Documentation

What changed and why

  • Fixed critical bug where rapidly clicking hide/unhide button corrupted video files
  • Added concurrency control to prevent race condition during file rename operations
  • File corruption resulted in 0 byte size, 00:00 duration, and "unsupported format" errors

Tests performed

  • Tested rapid clicking (2+ clicks) on hide button with videos - no corruption occurs
  • Verified both bottom action button and menu items work correctly
  • Tested on Samsung A24, Android 16
  • Confirmed fix prevents race condition while maintaining normal hide/unhide functionality

Before & after preview

Before: Clicking hide button twice quickly corrupts the video file

Video shows: 0 bytes size, 00:00 duration, "unsupported format" error

After: Multiple clicks are safely ignored while operation is in progress, file remains intact

Closes the following issue(s)

N/A - Critical production bug fix (allowed without prior issue per contribution guidelines)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (if applicable).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Fixes critical race condition when clicking hide button 2 times quickly.

Previously, clicking hide/unhide twice in quick succession would start two
concurrent file rename operations, causing file corruption (size becomes 0,
duration 00:00, unsupported format error).

Changes:
- Add mIsTogglingVisibility flag to track ongoing visibility toggle operations
- Check flag in click listener to prevent concurrent operations
- Clear flag in callback when operation completes

This ensures only one hide/unhide operation runs at a time, preventing
the race condition that corrupted video files.

Tested on Samsung A24, Android 16.
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.

1 participant