Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): improve memory handling of TiBlob image methods #11412

Merged
merged 14 commits into from
Mar 24, 2020

Conversation

garymathews
Copy link
Contributor

  • Allow GC to occur after memory intensive TiBlob image manipulation methods
TEST CASE
const win = Ti.UI.createWindow({ backgroundColor: 'gray' });
const img = Ti.UI.createImageView();
 
win.addEventListener('open', async () => {
 
    // Obtain large image blob. (8205px, 11750px)
    let blob = await getImage('https://tinyurl.com/rxob7ju');
 
    // Keep re-sizing the image down by 10%
    for (let i = 0; i < 10; i++) {
 
        // De-reference original blob so it can be freed.
        blob = blob.imageAsResized(blob.width / 1.1, blob.height / 1.1);
 
        // Idle for 100ms, allowing V8 GC to collect.
        // QE: Should not need to do this to display image.
        // await new Promise(resolve => setTimeout(resolve, 100));
    }
 
    // Display re-sized image.
    img.image = blob;
});
 
win.add(img);
win.open();
 
function getImage(url) {
    return new Promise((resolve, reject) => {
       const client = Ti.Network.createHTTPClient({
            onload(e) {
                resolve(e.source.responseData);
            },
            onerror: reject,
            timeout : 10000
        });
        client.open('GET', url);
        client.send();
    });
}
  • Should see re-sized image displayed

JIRA Ticket

@build build added this to the 9.0.0 milestone Jan 2, 2020
@build build requested a review from a team January 2, 2020 19:22
@build
Copy link
Contributor

build commented Jan 2, 2020

Warnings
⚠️ This PR has milestone set to 9.0.1, but the version defined in package.json is 9.1.0 Please either: - Update the milestone on the PR - Update the version in package.json - Hold the PR to be merged later after a release and version bump on this branch
Messages
📖

💾 Here's the generated SDK zipfile.

📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖

✅ All tests are passing
Nice one! All 9761 tests are passing.
(There are 905 skipped tests not included in that total)

Generated by 🚫 dangerJS against 317f73f

@sgtcoolguy
Copy link
Contributor

cc @brentonhouse this looks to be a potential "fix"/improvement for the workflow/use case you mentioned in the internal app.

@garymathews garymathews modified the milestones: 9.0.0, 9.0.1 Feb 11, 2020
@ssaddique
Copy link
Contributor

FR: Pass

@sgtcoolguy sgtcoolguy merged commit 1a72a45 into tidev:master Mar 24, 2020
sgtcoolguy pushed a commit that referenced this pull request Mar 24, 2020
*  implement v8 gc functionality
* attempt to reclaim memory when limited
* optimize TiBlob image manipulation methods for memory
* update to androidx

Fixes TIMOB-27695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants