Skip to content

fix: bundle video in app to prevent crash when not available#5886

Merged
NicolasMassart merged 6 commits intomainfrom
471_make_SRP_video_embeded_in_app
Mar 9, 2023
Merged

fix: bundle video in app to prevent crash when not available#5886
NicolasMassart merged 6 commits intomainfrom
471_make_SRP_video_embeded_in_app

Conversation

@NicolasMassart
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart commented Mar 2, 2023

Development & PR Process

  1. Follow MetaMask Mobile Coding Standards
  2. Add release-xx label to identify the PR slated for a upcoming release (will be used in release discussion)
  3. Add needs-dev-review label when work is completed
  4. Add needs-qa label when dev review is completed
  5. Add QA Passed label when QA has signed off

Description

Make the SRP video bundled in the app instead of retrieved from Github repos.

1. What is the reason for the change?
App crashed when video player tried to load the remote video and remote was not available (or network down or anything)

2. What is the improvement/solution?

  • Bundling the video in the app to prevent crash when remote not available
  • Keep remote subtitles as react-native-video only allow loading with remote url
  • Reduced video size from 5.7Mb to 1.9Mb with ffmpeg:
    #!/usr/bin/env sh
    
    VIDEO_BITRATE="75k"
    AUDIO_BITRATE="80k"
    
    ffmpeg -y -i recovery-phrase-source.mp4 -pass 1 -c:v libx264 -b:v $VIDEO_BITRATE -b:a $AUDIO_BITRATE -an -f null /dev/null && \
    ffmpeg -i recovery-phrase-source.mp4 -pass 2 -c:v libx264 -b:v $VIDEO_BITRATE -b:a $AUDIO_BITRATE recovery-phrase-mobile-2pass-optimized.mp4
    

image

The video is displayed by default on its original format on portrait mobile, meaning this video is most of the time around 5x3cm, very hard to see the quality diff when not really looking for it. Fullscreen makes it a bit more visible though. The source video is still in the repos (but not bundled in the app) and the above script allows to compress with higher bitrates if requested.

Source video

https://github.com/MetaMask/metamask-mobile/blob/471_make_SRP_video_embeded_in_app/app/videos/recovery-phrase-source.mp4?raw=true

Compressed video

https://github.com/MetaMask/metamask-mobile/blob/471_make_SRP_video_embeded_in_app/app/videos/recovery-phrase-mobile-2pass-optimized.mp4?raw=true

App size impact

The app size is only 1.9 additional Mb for the video. Makes it arround 27.7Mb for iOS and 274.6Mb for Android.

Issue

Relates to MetaMask/mobile-planning#471
fixes #5497

Testing

  • The parts that were unit testable are updated.
  • Video testing has been donne manually as no e2e exists to test the video and previous attempts to handle the player in e2e failed.

Here are the tests done:

  • Using a local http server I controlled access to the subtitles and was able to return errors or make it not respond: lack of access to subtitles only prevents them to show but doesn't crash and video plays fine.
  • No network at all (plane mode) as required in issue scenario GIVEN: User has NO access to internet (airplane mode): the app has a system preventing it to be used and requires the user to turn network on, so not relevant.
  • Slow network: subtitles appear with no noticeable delay as they are starting only at 00:00:00.780 so the loading time is before the display.
  • Tested video from the multiple places it plays in the app: onboarding, settings.

Test artifacts

TODO

test that the video player is not broken for other usecases (NFTs) -> requires a video NFT in the test wallet, will create and drop one for testing.

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 2, 2023

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

- use import instead of require
- declare mp4 as modules for import
- fix code format issues
@NicolasMassart NicolasMassart marked this pull request as ready for review March 3, 2023 18:49
@NicolasMassart NicolasMassart requested a review from a team as a code owner March 3, 2023 18:49
@NicolasMassart NicolasMassart added needs-qa Any New Features that needs a full manual QA prior to being added to a release. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Mar 3, 2023
@NicolasMassart NicolasMassart requested a review from sethkfman March 6, 2023 12:12
@cortisiko cortisiko removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Mar 6, 2023
@cortisiko
Copy link
Copy Markdown
Member

removing "needs-qa" since dev-review is still pending.

Copy link
Copy Markdown
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

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

LGTM

@sethkfman sethkfman added needs-qa Any New Features that needs a full manual QA prior to being added to a release. and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Mar 6, 2023
@holantonela
Copy link
Copy Markdown

Closes #5497

@NicolasMassart NicolasMassart removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Mar 9, 2023
Copy link
Copy Markdown
Contributor

@Andepande Andepande left a comment

Choose a reason for hiding this comment

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

  • Tested on physical Pixel 6
  • Tested on Browserstack devices (IOS/Android) while throttling network
  • QA PASSED

@Andepande Andepande added the QA Passed QA testing has been completed and passed label Mar 9, 2023
@NicolasMassart NicolasMassart merged commit 173b58e into main Mar 9, 2023
@NicolasMassart NicolasMassart deleted the 471_make_SRP_video_embeded_in_app branch March 9, 2023 16:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2023
@NicolasMassart NicolasMassart restored the 471_make_SRP_video_embeded_in_app branch March 9, 2023 18:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

QA Passed QA testing has been completed and passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundle the onboarding SRP explaining video in the app build

5 participants