Bug 64 - AdnroidGameView OnTouchEvent Object.GetObject NullReferenceException
Summary: AdnroidGameView OnTouchEvent Object.GetObject NullReferenceException
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 1.0
Hardware: All Other
: Normal critical
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2011-07-26 14:18 UTC by Benjamin Nitschke
Modified: 2012-03-12 21:56 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Benjamin Nitschke 2011-07-26 14:18:16 UTC
As previously reported at: https://bugzilla.novell.com/show_bug.cgi?id=692540

Description of Problem:
OpenGL application which is using touch input crashes randomly after some time
if touching the device. If no touches are done, the application remains stable.


Steps to reproduce the problem:
1. Create an opengl application, override AndroidGameView.OnTouchEvent and
touch around.


Actual Results:
Crashing the whole application.


Expected Results:
Not crashing.


How often does this happen? 
Depends on application and on touch behavior. Random timeframe from 1 second to
3 minutes. (When touching)


Additional Information:
Exception log:
01-02 00:18:14.170: INFO/MonoDroid(523): UNHANDLED EXCEPTION:
System.NullReferenceException: Object reference not set to an instance of an
object
01-02 00:18:14.170: INFO/MonoDroid(523): at Java.Lang.Object.GetObject
(intptr,System.Type,bool) <0x00104>
01-02 00:18:14.170: INFO/MonoDroid(523): at
Java.Lang.Object._GetObject<Android.Views.View> (intptr,bool) <0x0004f>
01-02 00:18:14.170: INFO/MonoDroid(523): at
Java.Lang.Object.GetObject<Android.Views.View> (intptr,bool) <0x0002b>
01-02 00:18:14.170: INFO/MonoDroid(523): at
Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_
(intptr,intptr,intptr) <0x00027>
01-02 00:18:14.170: INFO/MonoDroid(523): at (wrapper dynamic-method)
object.e768090b-ef91-4519-9021-fdc2044e373f (intptr,intptr,intptr) <0x00033>
01-02 00:18:14.200: WARN/dalvikvm(523): JNI WARNING: JNI method called with
exception raised
01-02 00:18:14.200: WARN/dalvikvm(523):              in
Ldelta/platforms/monodroid/MonoDroidGameView;.n_onTouchEvent
(Landroid/view/MotionEvent;)Z (GetStaticMethodID)
01-02 00:18:14.200: WARN/dalvikvm(523): Pending exception is:
01-02 00:18:14.200: INFO/dalvikvm(523): java.lang.Throwable:
System.NullReferenceException: Object reference not set to an instance of an
object
01-02 00:18:14.200: INFO/dalvikvm(523): at Java.Lang.Object.GetObject
(intptr,System.Type,bool) <0x00104>
01-02 00:18:14.200: INFO/dalvikvm(523): at
Java.Lang.Object._GetObject<Android.Views.View> (intptr,bool) <0x0004f>
01-02 00:18:14.200: INFO/dalvikvm(523): at
Java.Lang.Object.GetObject<Android.Views.View> (intptr,bool) <0x0002b>
01-02 00:18:14.200: INFO/dalvikvm(523): at
Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_
(intptr,intptr,intptr) <0x00027>
01-02 00:18:14.200: INFO/dalvikvm(523): at (wrapper dynamic-method)
object.e768090b-ef91-4519-9021-fdc2044e373f (intptr,intptr,intptr) <0x00033>
01-02 00:18:14.200: INFO/dalvikvm(523):     at
delta.platforms.monodroid.MonoDroidGameView.n_onTouchEvent(Native Method)
01-02 00:18:14.200: INFO/dalvikvm(523):     at
delta.platforms.monodroid.MonoDroidGameView.onTouchEvent(MonoDroidGameView.java:32)

The offending code seems to be located in this method. Maybe do some checks if
the given pointers are valid?

private static bool n_OnTouchEvent_Landroid_view_MotionEvent_(IntPtr jnienv,
IntPtr native__this, IntPtr native_e)
{
    View view = Object.GetObject<View>(native__this, false); // This line
produces the crash
    MotionEvent e = Object.GetObject<MotionEvent>(native_e, false);
    return view.OnTouchEvent(e);
}

[reply] [-] Comment 1 Benjamin Nitschke 2011-05-09 11:36:55 UTC

We had the same issue in the beta (reported in January already, but I cannot
find that bug here anymore).

[reply] [-] Comment 2 Heiko Schmitt 2011-05-09 15:26:21 UTC

Found same bug description here:
http://stackoverflow.com/questions/5829995/is-opengl-on-monodroid-stable

Also bug #685215 looks like the same issue.
https://bugzilla.novell.com/show_bug.cgi?id=685215
Comment 1 Miguel de Icaza [MSFT] 2012-03-12 21:56:29 UTC
MonoDroid has changed significantly and so has its OpenGL support and GC support, please reopen if you have a test case.