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(ios): report width/height of Blob as pixels, not points #11803

Merged
merged 2 commits into from Jul 13, 2020

Conversation

sgtcoolguy
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-27997

Optional Description:
With some sizes and scales, it is impossible to reconstruct the true number of pixels
in JS just with screen density/scale. We need to multiple image scale vs pts natively.
i.e. 10px square image on a 3x device reported width/height of 3, device scale of 3.
Multiplying in JS naively we'd get image size of 9px x 9px, which was incorrect.

Found when an image comparison test failed on #11699 which was the result of using a 10px x 10px view/image on a 3x simulator. (I knew about the points vs pixels issue, but had to work around it by forcing the view to use a multiple of 3 for it's size, since blob.width * Ti.Platform.displayCaps.logicalDensityFactor gave us 9)

With some sizes and scales, it is impossible to reconstruct the true number of pixels
in JS just with screen density/scale. We need to multiple image scale vs pts natively.
i.e. 10px square iumage on a 3x device reported width/height of 3, device scale of 3.
Multiplying in JS naively we'd get image size of 9px x 9px, which was incorrect.

Fixes TIMOB-27997
@sgtcoolguy sgtcoolguy added this to the 9.1.0 milestone Jul 2, 2020
@build build requested a review from a team July 2, 2020 21:13
@build
Copy link
Contributor

build commented Jul 2, 2020

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 6652 tests are passing.
(There are 698 skipped tests not included in that total)

Generated by 🚫 dangerJS against 832578c

Copy link
Contributor

@ssjsamir ssjsamir left a comment

Choose a reason for hiding this comment

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

FR Passed: Width/Height now returns the expected values, tested using the test case below.

Test case:

win = Ti.UI.createWindow();
const view = Ti.UI.createView({
  backgroundColor: 'green',
  width: '11px',
  height: '13px'
});
win.add(view);
win.addEventListener('postlayout', function postlayout() {
  win.removeEventListener('postlayout', postlayout);
  const blob = view.toImage();
  console.log('Value should = 11, Value = ' + blob.width);
  console.log('Value should = 13, Value = ' + blob.height);
});
win.open();

Result:

[INFO] �� � Value should = 11, Value = 11

[INFO] �� � Value should = 13, Value = 13

Test Environment

MacOS Big Sur: 11.0 Beta
Xcode: 12.0 Beta 
Java Version: 1.8.0_242
Android NDK: 21.3.6528147
Node.js: 12.18.1
""NPM":"5.0.0","CLI":"8.0.0""
iphone 8 Sim (14.0 Beta)

@sgtcoolguy sgtcoolguy merged commit 3c7c118 into tidev:master Jul 13, 2020
@sgtcoolguy sgtcoolguy deleted the blob-dimensions branch July 13, 2020 18:12
@ssaddique
Copy link
Contributor

ssaddique commented Aug 6, 2020

Fix verified on build 9.1.0.v20200804082025.

Test environment

OS Ver:         10.15.3
Xcode Ver:      Xcode 11.6
Appc NPM:       5.0.0
Appc CLI:       8.0.0
Node Ver:       10.17.0
Java Ver:       1.8.0_162
Simulator:      iPhone 11 Pro (13.6)

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.

None yet

5 participants