Skip to content

feat(scheme-handler): Improve memory usage & Range support - #1481

Merged
dpogue merged 2 commits into
apache:masterfrom
dpogue:scheme-handler
Aug 29, 2024
Merged

feat(scheme-handler): Improve memory usage & Range support#1481
dpogue merged 2 commits into
apache:masterfrom
dpogue:scheme-handler

Conversation

@dpogue

@dpogue dpogue commented Aug 28, 2024

Copy link
Copy Markdown
Member

Platforms affected

iOS

Motivation and Context

Improve memory usage and support range requests for resources loaded via a custom scheme.

Description

Changed the implementation of CDVURLSchemeHandler to do file reading on a background thread in 4MiB chunks rather than trying to load entire files into memory. 4MiB should be sufficient for most HTML/CSS/JS files, while still being low enough to not cause iOS to freak out about memory usage.

Improved URL building for file paths to ensure that things like query strings don't end up affecting which file gets loaded from the filesystem. Closes GH-909.

Also, implement support for the Range header to load subsections of files (mostly used for audio/video files) to further improve memory usage. Closes GH-1033.

Testing

Existing tests pass. All content for the mobile spec testcase loaded properly with these changes.

Checklist

  • I've run the tests to see all new and existing tests pass
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)

@dpogue dpogue changed the title Scheme handler feat(scheme-handler): Improve memory usage & Range support Aug 28, 2024
@dpogue dpogue added this to the 8.0.0 milestone Aug 28, 2024
@codecov-commenter

codecov-commenter commented Aug 28, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.22%. Comparing base (b6ae567) to head (82f9267).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1481   +/-   ##
=======================================
  Coverage   80.22%   80.22%           
=======================================
  Files          16       16           
  Lines        1871     1871           
=======================================
  Hits         1501     1501           
  Misses        370      370           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dpogue
dpogue force-pushed the scheme-handler branch 2 times, most recently from b9eab6c to de4dd9c Compare August 28, 2024 10:35
dpogue and others added 2 commits August 28, 2024 19:18
@dpogue
dpogue marked this pull request as ready for review August 29, 2024 02:19

@erisu erisu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Ran a test against a project that overrides scheme, project that contains all Apache Cordova plugins, & the Cordova's sample application.

@dpogue
dpogue merged commit 2cc8678 into apache:master Aug 29, 2024
@dpogue
dpogue deleted the scheme-handler branch August 29, 2024 10:14
OS-kepatotorica pushed a commit to OutSystems/cordova-ios that referenced this pull request Aug 14, 2025
* refactor(schemes): Read files on a background thread

Closes apacheGH-909.

* feat(schemes): Support range requests

Based on code from ionic-team/cordova-plugin-ionic-webview#692

Closes apacheGH-1033.

Co-Authored-By: David Holmgren <dodahoho@users.noreply.github.com>

---------

Co-authored-by: David Holmgren <dodahoho@users.noreply.github.com>
sonlichao added a commit to dejiren/cordova-ios that referenced this pull request Oct 21, 2025
* refactor(schemes): Read files on a background thread

Closes apacheGH-909.

* feat(schemes): Support range requests

Based on code from ionic-team/cordova-plugin-ionic-webview#692

Closes apacheGH-1033.

Co-Authored-By: David Holmgren <dodahoho@users.noreply.github.com>

---------

Co-authored-by: David Holmgren <dodahoho@users.noreply.github.com>
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.

Reading big media files make WKWebView crash with cordova-ios-6.x 404 when startpage contains a query string and protocol/scheme are specified

3 participants