-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(android): improve memory handling of TiBlob image methods (#11412)
* implement v8 gc functionality * attempt to reclaim memory when limited * optimize TiBlob image manipulation methods for memory * update to androidx Fixes TIMOB-27695
- Loading branch information
1 parent
411f2de
commit 26982f3
Showing
5 changed files
with
171 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2020 by Axway, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
/* eslint-env mocha */ | ||
/* eslint no-unused-expressions: "off" */ | ||
'use strict'; | ||
var should = require('./utilities/assertions'); | ||
|
||
describe('Titanium.Blob', function () { | ||
var win; | ||
|
||
afterEach(function (done) { | ||
if (win) { | ||
// If `win` is already closed, we're done. | ||
let t = setTimeout(function () { | ||
if (win) { | ||
win = null; | ||
done(); | ||
} | ||
}, 3000); | ||
|
||
win.addEventListener('close', function listener () { | ||
clearTimeout(t); | ||
|
||
if (win) { | ||
win.removeEventListener('close', listener); | ||
} | ||
win = null; | ||
done(); | ||
}); | ||
win.close(); | ||
} else { | ||
win = null; | ||
done(); | ||
} | ||
}); | ||
|
||
it('resize very large image', function (finish) { | ||
|
||
win = Ti.UI.createWindow({ backgroundColor: 'gray' }); | ||
const img = Ti.UI.createImageView(); | ||
|
||
// Obtain large image blob. (8000px, 8000px) | ||
let blob = Ti.Filesystem.getFile('large.jpg').read(); | ||
should(blob).be.an.Object; | ||
|
||
win.addEventListener('open', () => { | ||
|
||
// 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); | ||
should(blob).be.an.Object; | ||
} | ||
|
||
// Display re-sized image. | ||
img.image = blob; | ||
|
||
finish(); | ||
}); | ||
|
||
win.add(img); | ||
win.open(); | ||
}); | ||
}); |