Bug 25727 - Touch coordinates inaccurate on physical device
Summary: Touch coordinates inaccurate on physical device
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.6.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-01-05 18:17 UTC by Cody Beyer (MSFT)
Modified: 2017-07-26 17:53 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Cody Beyer (MSFT) 2015-01-05 18:17:42 UTC
### Description

When using a TouchPanel the GetPosition method returns invalid coordinates, and does not extend to the edge of the screen

### Test Case


### Video


### Reproduction Steps

1. Open attached test case
3. Go into Landscape
4. Touch the screen at the very very bottom

### Expected Results

The white touch dot should be at the very bottom of the screen and have a coordinate of 640

### Actual Results

The white touch dot never fully goes to the bottom, and provides a coordinate of around 626

### Version

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 3e4348fa-e0b3-46a4-8426-58f27e19159e
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 2c57f4e
Build date: 2014-12-18 16:42:49-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.10.1
Darwin Codys-MBP.lan 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2015-01-05 22:41:50 UTC

1. Your solution is incomplete. It does not contain the MonoGame.Framework.iOS project and won't compile.

2. A `TouchPanel` is not a type that Xamarin.iOS ships. It's (very likely) part of MonoGame, which is not something we support.
Comment 2 Cody Beyer (MSFT) 2015-01-05 22:47:40 UTC

Sorry, I uploaded the wrong zip. Here you go: https://www.dropbox.com/s/gaqrlv53ygzedgh/TouchRepro.zip?dl=0
Comment 3 Adam Kapos 2015-01-06 20:12:45 UTC
While the sample project includes MonoGame, if you look at the positions provided by iOS to MonoGame you can see that they are wrong.
Comment 4 Sebastien Pouliot 2015-01-06 20:41:11 UTC
AFAICT the values are not wrong (e.g. there's no offset), it's where the last touches were reported by the application.

IOW it seems that iOS (likely for the control center swipe*) is not giving the application all of the touch events that comes from the screen (i.e. it swallows some).

Different resolutions are "reserving" a different amount of pixels, e.g.

2x scale: 10 pixels (i get 628, and the max is 638 since it's doubling, non fractional and zero-based)

3x scale: 20 pixels (I get 1105 and the max is 1125, here fractional position are reported by iOS).

* I remember reading something about this, I'll try to find the link again and see if some solution were proposed.
Comment 5 Adam Kapos 2015-01-06 20:45:26 UTC
My iPhone is reporting on the Y axis from 0 to 623 and it stays at 0 for the top part of the screen. This makes hitting a button on the top of the screen a real challenge.
Comment 6 Sebastien Pouliot 2015-01-06 20:53:53 UTC
I do not see this behaviour (at the top). Everything is linear but stops a few 10-20 pixels from the bottom of the screen.

Can you tell us which device(s) you're using and which iOS versions they run ? I'll try to get the closest I can (or find someone else with a more similar setup)
Comment 7 Adam Kapos 2015-01-06 21:02:29 UTC
I observed it on an iPhone 4S running 7.1 and an iPod Touch (latest) running 8.1.

Observe the touch on top of the screen more carefully. It isn't linear (stays 0 for a while then becomes linear). Compare it with the bottom to see the difference.
Comment 8 Sebastien Pouliot 2015-01-06 21:15:43 UTC
What I see looks linear to me, except it says at 0 when my finger gets offscreen (might be easier to notice with a 6+ bigger screen). When I move lower (on the screen) the values start incrementing linearly down to the bottom.

Now I do not get this issue when using XI alone, i.e. a similar sample without MonoGame. 

2015-01-06 21:00:17.919 TouchTest[694:247140] {X=141.333312988281, Y=368.333343505859}

It might not be MonoGame itself (as the iOS values are not received on the bottom of the screen), but it could be some bad interaction between GLES and UIKit, inside iOS itself.

I'll try a few other things (workaround ideas) but this is not an XI bug.
Comment 9 Adam Kapos 2015-01-09 08:59:10 UTC
Any updates regarding the workaround?
Comment 10 Adam Kapos 2015-01-10 08:50:07 UTC
Here is a video that shows the offset:
Comment 11 Adam Kapos 2015-01-23 11:16:03 UTC
It's been two weeks and we really need a workaround for this critical bug.
Comment 12 Sebastien Pouliot 2015-01-23 12:24:00 UTC
I'm out of town for meetings and will only be back next week. 

Note that this is an iOS bug and, while I'll _try_ to find a workaround, I cannot guarantee I will find one (or that one exists, beside not using OpenGLES).
Comment 13 Adam Kapos 2015-02-03 17:34:19 UTC
I guess it's next week already :)
Comment 14 John Miller [MSFT] 2017-07-26 17:53:28 UTC
I attempted to reproduce this issue based on the bug description with the latest Xamarin.iOS, and I was unable to hit the problem. If this issue is still occurring for you, please reopen this report and attach a project that reproduces the issue, ideally starting with a new template project and then adding just the code necessary to demonstrate the issue. 

Note* I had to convert the TouchRepro project to Unified and I instead referenced MonoGame.Framework.iOS from NuGet.