[TIMOB-19779] Android orientations on orientationchange not providing accurate results in some Android Tablets
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2017-11-06T18:16:59.000+0000 |
Affected Version/s | Release 5.0.1, Release 5.0.2, Release 5.0.0 |
Fix Version/s | n/a |
Components | Android |
Labels | orientations |
Reporter | Ricardo Ramirez |
Assignee | Joshua Quick |
Created | 2015-10-23T20:22:21.000+0000 |
Updated | 2017-11-06T18:17:04.000+0000 |
Description
Issue description
With the new Titanium SDK, SINCE 4.1.0, Android tablets that have their default orientation in landscape are reporting it's orientation as portrait when it is actually landscape and landscape when it is actually portrait. The customer experienced this issue using the Samsung Galaxy Tab 3 model GT-P5210.
Steps to replicate
-Create a new titanium alloy project
-Open the app folder
-Replace the index.xml file inside views folder, the index.tss file inside styles folder and the index.js file inside controllers
-Change orientation in emulator
-Build and run
-Device Orientation is sometimes detected as portrait when it is actually landscape and landscape when it is actually portrait
Attachments
File | Date | Size |
index.js | 2015-10-23T20:22:04.000+0000 | 1486 |
index.tss | 2015-10-23T20:22:13.000+0000 | 388 |
index.xml | 2015-10-23T20:21:57.000+0000 | 140 |
PR: https://github.com/appcelerator/titanium_mobile/pull/7455
I'm wondering if this ticket is related? [TIMOB-19878]
[~dawsontoth] Seems very similar, but on my tests and according to the customer shared info, the event was triggered but it was sending wrong info and not every time, I was not able to reproduce it (even in Gennymotion) but i had 2 customers with this issue if you see at the Github PR, the engineering team reproduced and solved the issue. I just have one question [~msamah], this PR was inserted on the now released SDK 5.1.0.GA or this solution still in review ?
[~cng] [~msamah] In which version is or will be the fix ?
[~rramirez] This is in master branch for 5.2.0 release.
Thanks !
Verified the fix. orientationchange now returns accurate orientation on tablets. Closing. Environment: Appc Studio : 4.5.0.201601131150 Ti SDK : 5.2.0.v20160114021251 Ti CLI : 5.0.5 Alloy : 1.7.26 MAC Yosemite : 10.10.5 Appc NPM : 4.2.3-1 Appc CLI : 5.2.0-231 Node: v0.12.27 Samsung Galaxy Tab SM-600 - Android 4.3
Unfortunately this still isn't fixed perfectly Create an app and add following Ti.Gesture.addEventListener('orientationchange', function(){ console.log("orientationchange fired"); }); Deploy to an Android tablet Now hold the device in portrait and position horizontally flat, mid air Now tilt device one corner of the device up slightly and rotate round towards it being in a landscape position Note how the console.log("orientationchange fired") has not been executed even though the screen has orientated
What device are you using and which Android version is it running?
Nexus 10 ( Android 4.4.2 ) and Nexus 9 ( Android 6.0 )
You are using Titanium SDK 5.2.0.GA?
Yes 5.2.0.GA
Hello, I have tested the issue on Galaxy tab 4 (Android 4.4.2) with SDK 5.2.0.GA. I could not reproduce this issue. I followed the below instructions: 1.Deploy to an Android tablet 2.Hold the device in portrait and position then horizontally flat in mid air 3.Now, tilt device one corner up slightly and rotate around towards it being in a landscape position. 4.See for orientationchange event in console log. Following these steps, when the device changes the orientation the app detects it and fired the change event perfectly. Now, when I tried with SDK 5.1.0.GA I see that the fired event provides the wrong mode in console for 2-3 times. After that, it starts providing the right mode.
Unable to reproduce. If there are instructions or more details on how to reproduce, please comment. I'll resolve this as unable to reproduce if there isn't more movement on this in a few days.
Looking at this - could the issue be related to how sensitive the device accelerometer is, and in turn how much information it reports back for the SDK to determine a correct value to report? For example - when @Louis and I typically see this issue - a device is rotated slowly, placed on a table carefully, or in the process of some other 'slower' action. Essentially - undertaking user actions that would trigger a device's accelerometer to report back more refined values.
That's an interesting hypothesis. Does it work correctly if you turned it at a normal speed? And what's considered a
slower
action?Typically, a 'quick' movement (e.g. a sharp or 'normal speed' turn from portrait to landscape) would see the UI update correctly in a majority of cases. But a slower movement (e.g. a gradual turn and tilt - in the same kind of manner you would if you were playing a gravity / physics based game such as Labyrinth - or if you were carefully placing a device face up, onto a table) would trigger the error more frequently. Our theory was that once in the device accelerometer (or logic) gets into this state, it reports back in the same manner, until another 'sharp' action breaks the process (perhaps the flow inside here: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/gesture/src/java/ti/modules/titanium/gesture/GestureModule.java - might have some link to that?).
Please try this code index.xml:
[~louis.quaintance] Thanks for that code. Able to reproduce the bug with what you have provided.
I am also having orientation issue with Nexus 10 device. I put alerts in orientation handing code. The alert shows wrong code for orientations sometimes. It displays portrait code for landscape orientations and landscape codes for portrait orientations. I have used Titanium SDK: 5.2.2.GA Appcelerator Studio: 4.5.0 Project Type: Alloy. {quote}Orientaiton code block:{quote} { function handleOrientationchange(e) { alert('Latest Orientation: ' + e.orientation); if (e.orientation != prevOrientation && OrientationFlag == false && e.orientation >= 1 && e.orientation <= 4) { OrientationFlag = true; if (e.orientation == Titanium.UI.UPSIDE_PORTRAIT || e.orientation == Titanium.UI.PORTRAIT) { ... } else if (e.orientation == Titanium.UI.LANDSCAPE_RIGHT || e.orientation == Titanium.UI.LANDSCAPE_LEFT) { ... } prevOrientation = e.orientation; OrientationFlag = false; } } Ti.Gesture.addEventListener("orientationchange", handleOrientationchange); }
[~mobihunterz] May I know which version of Android is being used as well?
I am also experiencing this issue. Happens also Nexus 7 and 9 simulator, SDK 5.2.2.GA.
[~arif] Just want to know more background on this, what's the use case you are using this for?
Hi Ashraf, we're using it to change the UI layout for landscape vs portrait. When the user switches to landscape, we show another layout / extra columns. I've made a screencast of the issue, you can watch it here: https://streamable.com/a9qk I also made a testproject, you can download it here: https://file.io/eZ7EQ1 As you can see, the first time the device changes orientation, there's no output in the console, so it doesn't seem to detect the change. The second change, it detects the change, but wrong; landscape is detected as portrait from then on and the other way around. This is the issue with every tablet in the simulator, but I also happens on real Nexus devices.
Thanks for the screencast. That looks like a bad bug. Will need to get this investigated.
I've put the ticket in Triage for now.
great, thanks!
[~mobihunterz] I'm using
And having a hard time reproducing your error.
I am still having this issue with SDK 5.4.0.GA, on multiple simulators and different Android versions. And it doesn't happen on tablets only! A clean window with orientation listener won't detect the first orientation change. The second time it detects the change, but wrong. Screencast:https://streamable.com/r1r9 Project: http://content3.skoften.net/temp/testje.zip Running on OSX. Studio 4.7.0.201607250649. EDIT: I just tested it on 2 real devices (S6 and S6 Edge) and it works. Maybe it's an simulator-issue? Using Genymotion.
Using e.source.orientation solved it for me. if(e.source.orientation == Titanium.UI.LANDSCAPE_RIGHT || e.source.orientation == Titanium.UI.LANDSCAPE_LEFT){ //Do Something }else if(e.source.orientation == Titanium.UI.PORTRAIT || e.source.orientation == Titanium.UI.UPSIDE_PORTRAIT){ //Do Something }
[TIMOB-24537] resolves this. It'll introduces a breaking change where Ti.Gesture provides device orientation instead of app window orientation, like how it works on iOS and Windows Phone.