[mono-android] Tracking GlobalReferences

2012-02-04 Thread NebulaSleuth
I have been working to find lost Global References in my application.  I have
been able to find and address just about everything, but I have some
questions about the information in the debug.mono.log data.

First I seem to get a recurring Global Reference allocation with the *same*
address, that never seems to be deallocated.  But the information doesn't
point me to anywhere that I can find in my code.  I was hoping someone had
an idea of what a NoClassDefError might be related to.  It seems to occur
shortly after each GC pass.  So I lose a global handle every ~30s or so. 

The handle is always the same: 0x4001518

--

I/monodroid-gref(18413): +g+ grefc 245 gwrefc 0 obj-handle 0x40015158/L ->
new-handle 0x40015158/L fromat
Java.Lang.Object.RegisterInstance(IJavaObject instance, IntPtr value,
JniHandleOwnership transfer)
I/monodroid-gref(18413):at Java.Lang.Throwable.SetHandle(IntPtr value,
JniHandleOwnership transfer)
I/monodroid-gref(18413):at Java.Lang.Throwable..ctor(IntPtr handle,
JniHandleOwnership transfer)
I/monodroid-gref(18413):at Java.Lang.Error..ctor(IntPtr javaReference,
JniHandleOwnership transfer)
I/monodroid-gref(18413):at Java.Lang.LinkageError..ctor(IntPtr
javaReference, JniHandleOwnership transfer)
I/monodroid-gref(18413):at Java.Lang.NoClassDefFoundError..ctor(IntPtr
javaReference, JniHandleOwnership transfer)
I/monodroid-gref(18413):at
System.Reflection.MonoCMethod.Invoke(System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture)
I/monodroid-gref(18413):at
System.Reflection.MonoCMethod.Invoke(BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture)
I/monodroid-gref(18413):at
System.Reflection.ConstructorInfo.Invoke(System.Object[] p
I/monodroid-gref(18413): handle 0x40015158; key_handle 0x40015158: Java
Type: `java/lang/NoClassDefFoundError`; MCW type:
`Java.Lang.NoClassDefFoundError`

-

Secondly, I have a recurring allocation that seems to be freed during GC,
but then gets 'resurrected' in a second phase.  It seems to be related to a
weak reference, but again it doesn't give me much to go on other than it
seems to be a string.

---
I/monodroid-gref(20680): +g+ grefc 288 gwrefc 0 obj-handle 0x405557a0/L ->
new-handle 0x405557a0/L fromat
Java.Lang.Object.RegisterInstance(IJavaObject instance, IntPtr value,
JniHandleOwnership transfer)
I/monodroid-gref(20680):at Java.Lang.Object.SetHandle(IntPtr value,
JniHandleOwnership transfer)
I/monodroid-gref(20680):at Java.Lang.Object..ctor(IntPtr handle,
JniHandleOwnership transfer)
I/monodroid-gref(20680):at Java.Lang.String..ctor(IntPtr javaReference,
JniHandleOwnership transfer)
I/monodroid-gref(20680):at
System.Reflection.MonoCMethod.Invoke(System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture)
I/monodroid-gref(20680):at
System.Reflection.MonoCMethod.Invoke(BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture)
I/monodroid-gref(20680):at
System.Reflection.ConstructorInfo.Invoke(System.Object[] parameters)
I/monodroid-gref(20680):at
Android.Runtime.TypeManager.CreateProxy(System.Type type, IntPtr handle,
JniHandleOwnership transfer)
I/monodroid-gref(20680):at
Android.Runtime.TypeManager.CreateInstance(IntPtr handle, Jn
I/monodroid-gref(20680): handle 0x405557a0; key_handle 0x405557a0: Java
Type: `java/lang/String`; MCW type: `Java.Lang.String`

...

I/monodroid-gref(20680): -g- grefc 267 gwrefc 23 handle 0x40553428/G from
take_weak_global_ref_jni
I/monodroid-gref(20680): *take_weak obj=0x51503cb0 -> wref=0xde5a99d7
handle=0x405557a0
I/monodroid-gref(20680): +w+ grefc 267 gwrefc 24 obj-handle 0x405557a0/G ->
new-handle 0xde5a99d7/W from take_weak_global_ref_jni
...

I/monodroid-gref(20680): *try_take_global obj=0x51503cb0 -> wref=0xde5a99d7
handle=0x405557a0
I/monodroid-gref(20680): +g+ grefc 248 gwrefc 24 obj-handle 0xde5a99d7/W ->
new-handle 0x405557a0/G from take_global_ref_jni
I/monodroid-gref(20680): -w- grefc 248 gwrefc 23 handle 0xde5a99d7/W from
take_global_ref_jni
---


I am concerned about both of these since the total reference count seems to
continue to go up on each of these, but never goes back down (at least when
running for hours).

--

I have written a tool that I have been using to help track the GRefs.  You
can download a copy  http://www.extrastrength.com/files/GRefMonitor.exe here 

Hopefully, someone will find it useful.

-Mike



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Tracking-GlobalReferences-tp5457139p5457139.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_

Re: [mono-android] Nook apps

2012-02-04 Thread NebulaSleuth
You can get the nook to show up in adb by side loading an application that
allows you to enable debugging mode and installing the appropriate drivers. 
You don't have to root the device to make it work, but I found it very
helpful to do so.

you can find info here:

http://forum.xda-developers.com/showthread.php?t=1354487





--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Nook-apps-tp5445160p5457249.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Tracking GlobalReferences

2012-02-05 Thread NebulaSleuth
Thanks, I look forward to the 4.04 release. Any idea how long it will be?

I don't suppose you guys have an errata that shows all the known gref leaks? 
This would be useful for avoiding them, and at least prevent me from chasing
red herrings all day.

As for the "other" leak I mentioned with strings, it seems to be related to
changing the "text" property of a TextView. 

 as in:  "TextView.Text = TranslationLookup(TextView.Text);"

Which is something I do whenever the user changes language settings.  The
translation lookup simply returns an existing string from a dictionary, so
it doesn't actually allocate anything.

But, this seems to allocate a new GRef, and doesn't free up one. These stale
grefs get freed when I launch a new activity, but as long as the main
activity still runs, it holds on to it.  Although it attempts to free it on
each subsequent GC, but then resurrects it again.  It will continue to do
this over and over.

Generally most apps won't care too much as they are not meant to run
continuously.  However, my app runs 24/7 and eventually will die if it has
any leaks.  This would be bad. :)

Thanks again. 



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Tracking-GlobalReferences-tp5457139p5458167.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


[mono-android] 4.2.1 issues

2012-05-15 Thread NebulaSleuth
First let me say.  I like some of the things in 4.2.x.  Good direction guys. 
But there are a few things I am having issues with since the 4.2.1 upgrade.
I am using VS2010. I went from 4.06 to 4.2.1.

1. Even though I compile with no warnings or errors, shortly after
compiling, I get "intellisense" errors in some of the files open in the
editor.  The errors are as if references to other class libraries are not
setup, but of course they are since it compiled properly.  This might be
related to class libraries that are referenced within other class libraries. 
So if the app has a reference to class1.methodA that is in a library, and
methodA returns a type class2 which is defined in a second library, there is
a intellisense error in the call complaining  that it: 

"Cannot implicitly convert class2 to namespace.class2".  When of course they
are the same reference.  

2. VS2010 crashes periodically if the debugger is left attached for a while. 
Doing long duration testing (> 1-2 hrs), the VS2010 will simply crash and
have to restart.  

3. Every time an application is deployed, it removes the previous version. 
This wipes out any local storage, so any configuration files, or downloaded
files etc, are wiped out.  This is a real pain, as my application needs to
be reconfigured (told the server IP address) , and then it needs to
re-download about 200MB  of data, every time I recompile and debug. Ouch!!!

4. NetworkInterface.GetAllNetworkInterfaces()  seems to not function any
more.  Is there an alternative?




--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/4-2-1-issues-tp5709753.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] 4.2.1 issues

2012-05-15 Thread NebulaSleuth
Sweet!  It worked.  Thanks.

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/4-2-1-issues-tp5709753p5709755.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] 4.2.1 issues

2012-05-15 Thread NebulaSleuth

Jonathan Pryor-2 wrote
> 
> On May 15, 2012, at 11:24 AM, NebulaSleuth wrote:
>> 4. NetworkInterface.GetAllNetworkInterfaces()  seems to not function any
>> more.
> 
> It's never worked: 
> 
>   https://bugzilla.novell.com/show_bug.cgi?id=661106
>   https://bugzilla.xamarin.com/show_bug.cgi?id=1969
> 

Very interesting.  Guess I never noticed before.  I was using it in some
shared code, and never noticed that it was failing on the android builds. 
Good to know.


2 down... 2 to go...
Thanks


--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/4-2-1-issues-tp5709753p5709763.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Designer Error

2012-05-15 Thread NebulaSleuth
I had the same problem.  It was because my design file used an 
statement.

It appears that the designer doesn't like it, or has a problem resolving the
path.  This is unfortunate because I use them whenever I have a
 element.  That way my xml isn't so messy.


something like:






Hope this helps.  It was my cause for that same error.

Anyone have a solution to this?

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Designer-Error-tp5709771p5709774.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Designer Error

2012-05-16 Thread NebulaSleuth

Lluis Sanchez Gual wrote
> 
> 
>> I am unable to reproduce this problem. Can you send me a sample layout
>> (+included files) I could use to reproduce the error?
>> 
> 

So I was going to give you an example, but I wanted to simply it first.  So
what I found was very strange indeed.

If I created a NEW layout using "rightclick on layout->add->new
item->Android Layout"  and then copied the contents from an included layout
that didn't work, and then changed the include to refer to the new file.
Voila it started to work.

The contents of the new file are identical to the original file, just that
it is a different file.  If I change the include to point back to the old
file, it fails again. 

So I suspect, if I give you the files, it will probably work for you. 

The project was converted from a Mono 4.0.6 project, so it might have
something to do with it.  Not sure what is confusing it, but there is a
workaround. :)

I also am using VS2010 on Win7 x64.





--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Designer-Error-tp5709771p5709841.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Designer Error

2012-05-17 Thread NebulaSleuth

moljac wrote
> 
> Does
> Visual Studio +/ Advanced Save Settings +/ Unicode without signature 
> (Codepage xx)
> helps?
> 
> I thnik MS guys are calling it Signature and not BOM...
> 
> mel
> 
> 

I can confirm, that changing file->advanced save options to "Unicode (UTF-8
without signature) - Codepage 65001" solves the problem.

Thanks

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Designer-Error-tp5709771p5709859.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Resources in Class Library project

2012-05-18 Thread NebulaSleuth
I tried this as well with no luck.  I am also running 4.2.1.

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Resources-in-Class-Library-project-tp5658638p5709916.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Build warnings (MonoDevelop)

2012-06-27 Thread NebulaSleuth
I get the same warning.  This is a big problem. Since it can't overwrite the
file, the debug session doesn't work properly.  It can't properly set break
points.  Basically, every time I make a code change, if I want to debug with
a breakpoint I have to exit visual studio and restart.

This makes debugging code extremely tedious.

Hopefully somebody has an idea of how to fix this.  

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Build-warnings-MonoDevelop-tp5709839p5710617.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Build warnings (MonoDevelop)

2012-06-29 Thread NebulaSleuth
Thanks.  Unlocker helps, but what a pain.  

Hopefully they will fix this in the next version.  I can hardly use
breakpoints at all in this version.



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Build-warnings-MonoDevelop-tp5709839p5710682.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


[mono-android] Sensor Handler loses GREF handles

2012-09-04 Thread NebulaSleuth
I have a problem where my application seems to lose GREF's very quickly.  I
tracked it down to the Sensor handler.  Basically after running for about an
20 minutes my application becomes unresponsive (very slow) and produces and
ANR dialog.  

The problem seems to be in my Sensor Handler, but for the life of me I don't
know what is wrong.  I have boiled it down to simply reading the X,Y,Z data.  

If I do that, a GREF gets lost and eventually, (within 15-20 minutes) I hit
the 46800 maximum GREF count which causes a full GC pass which frees some
up, then it hits the max again fairly quickly, and the process repeats. This
is causing the app to run VERY slow.

The code is very simple:

in OnResume():
SensorManager sm =
(SensorManager)GetSystemService(SensorService);
if (sm != null)
{
sm.RegisterListener(this,
sm.GetDefaultSensor(SensorType.Accelerometer), SensorDelay.Game);
}

in OnPause():
SensorManager sm =
(SensorManager)GetSystemService(SensorService);
if (sm != null)
{
sm.UnregisterListener(this);
}

and the handler:
public void OnSensorChanged(SensorEvent sensorEvent)
{
   // If I don't do the following three lines, GREF counts don't go
haywire
float X = sensorEvent.Values[0];
float Y = sensorEvent.Values[1];
float Z = sensorEvent.Values[2];
// sensorEvent.Dispose(); //Dispose does not seem to help
}

Am I forgetting/missing something?  It seems pretty simple.

-Mike





--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Sensor-Handler-loses-GREF-handles-tp5711686.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


[mono-android] Help with Activity.Finish

2011-12-29 Thread NebulaSleuth
I have an Activity that starts a second activity using
StartActivityForResult().

The second activity starts fine, and then spawns a thread to do some work. 
When the work is complete I want to return to the calling Activity by
calling SetResult() and Finish().

The problem is control doesn't return to the calling activity, the
application screen goes away (back to the launcher screen) and the debugger
never returns as if the app is hung.  

I figured that I needed to do it from the UI Thread so I tried using
RunOnUIThread() to perform the SetResult/Finish.  Still no luck.

So I created a Handler and used SendMessage to perform the action.  Still no
luck.

as a test, I then spun after starting the thread, checking the IsAlive flag
until the thread completed and then called SetResult/Finish.  Well that
worked!  However, this is not really useful.

Can somebody shed some light on what is happening here?

-Mike

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Help-with-Activity-Finish-tp5109329p5109329.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


[mono-android] Breakpoints suddenly stopped working!

2012-01-06 Thread NebulaSleuth
I have 2 workstations.  Both were working fine yesterday.  At some point last
night, I got an error on my primary machine where it said something like
"unable to build package". 

So I did a rebuild all and everything seemed fine, but I really didn't
deploy and test anything.

This morning, when I began working, I noticed that my breakpoints were not
being triggered.  The code seemed to merrily bypass them and keep running. 
I put a breakpoint on the first line in OnCreate and it never stops.  The
application just boots and starts running.

I tried the same code on my laptop, and it worked fine. It Hit the
breakpoint and allowed me to step.

I tried on the emulator instead of my target device and it still failed to
stop at the breakpoint on the main workstation.

I rebooted the PC, the device, the emulator... no joy.
I uninstalled mono, and the android SDK, deleted the xamarin registry group,
and re-installed.  no joy.

I tried it on a native window application and it works perfectly.  But not
on an android device/emulator.

*My primary workstation no longer stops at breakpoints but my laptop, works
fine.

HEELPPP
*


--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Breakpoints-suddenly-stopped-working-tp5126366p5126366.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Breakpoints suddenly stopped working!

2012-01-06 Thread NebulaSleuth
Ok, after uninstalling everything again, deleting all the directories,
including the .android folder and the registry settings, AND restoring the
project file from a previous backup, it starting working again.

Although doing the uninstall and reinstall solved the problem for new
projects, it still failed for my actual project.  Restoring a previous
version and copying over the source files resolved the issue.

???!?!?

Whatever, only 6 hours lost :(



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Breakpoints-suddenly-stopped-working-tp5126366p5126903.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid