ionic-team / ionic-team/cordova-plugin-ionic-webview

iOS - Playing local video files uses huge amount of memory

Open
#378 35 comments 4 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
493
Forks
410
PR merge metrics
No merged PRs in 30d

Description

### Context

I have an app which downloads video files (.mp4) from AWS, stores them locally, and plays them using an HTML5 video tag.

### Issue

When the app loads the component, I see a huge peak in RAM usage (my app uses 40mb in average, and I see peaks up to 500mb). This is really an issue because it makes the webview crash (white screen + reloading) with most of my videos (which are 200-300mb each).

If I try to play the video directly from the server, it works fine (no memory peak).

I don't have a lot of experience with videos and streaming, but it seems that the webview tries to load the whole video file when the component is loaded, instead of streaming the video.

### Environment

- I'm using Ionic@4 + cordova-plugin-ionic-webview@4.0.1.
- I used to play videos the same way with Ionic@3 + cordova-plugin-ionic-webview@2 without any issue
- I use `@ionic-native/file-transfer` to store the files locally
- iPad with iOS 11.3

### Code

#### component.html

```

```

#### component.ts
```
import { SafeUrl, DomSanitizer } from '@angular/platform-browser';
...
constructor(private sanitizer: DomSanitizer) { }
...
// assetLocalUrl is the file's local URL on the device, returned by window.Ionic.WebView.convertFileSrc()
this.backgroundVideoURL = this.sanitizer.bypassSecurityTrustUrl(assetLocalUrl);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.