Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Context: https://bugzilla.xamarin.com/25/25443/bug.html#c23 Context: xamarin/monodroid@bf9dc9e Once upon a time, JNI Global Reference (GREF) and JNI Local Reference (LREF) logging was written only to `adb logcat`. This worked, until it didn't work; around Android 5.0, [`__android_log_print()`][0] appeared to become "less reliable", and `adb logcat` would no longer "reliably" contain all GREF messages. We "fixed" this in xamarin/monodroid@bf9dc9ee (2015-Feb-6) by writing GREF messages to `grefs.txt`. While this improved reliability, there was a "usability" cost: `grefs.txt` can only be accessed if the app is ["debuggable"][1], which isn't necessarily easy (requires rebuilding from source), and hinders diagnosis and review. Add new `gref+` and `lref+` options, which re-introduce spamming `adb logcat` with GREF and LREF messages: adb shell setprop debug.mono.log 'gref+,lref+' This will allow non-debuggable apps to produce accessible GREF logs: adb logcat > log.txt & msbuild /t:StartAndroidActivity App.csproj …and (again!) *spam* logcat: monodroid-gref: +g+ grefc 5 gwrefc 0 obj-handle 0x7fc13ebc70/I -> new-handle 0x29e6/G from thread '(null)'(1) monodroid-gref: at Android.Runtime.AndroidObjectReferenceManager.CreateGlobalReference (Java.Interop.JniObjectReference value) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Java.Interop.JniObjectReference.NewGlobalRef () [0x00000] in <66190dc38bc34d07af752fceda80105a>:0 monodroid-gref: at Android.Runtime.JNIEnv.NewGlobalRef (System.IntPtr jobject) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.Runtime.AndroidValueManager.AddPeer (Java.Interop.IJavaPeerable value, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.IntPtr& handleField) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Java.Lang.Object.SetHandle (System.IntPtr value, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Java.Lang.Object..ctor (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.Content.Context..ctor (System.IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.Content.ContextWrapper..ctor (System.IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.Views.ContextThemeWrapper..ctor (System.IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.App.Activity..ctor () [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at HelloWorld.MainActivity..ctor () [0x00000] in <01eae2bf5ab14181a2c9706cec17ab4e>:0 monodroid-gref: at Android.Runtime.DynamicMethodNameCounter.3 (System.IntPtr , System.Object[] ) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Java.Interop.TypeManager.Activate (Java.Interop.IJavaPeerable o, System.IntPtr jobject, System.Reflection.ConstructorInfo cinfo, System.Object[] parms) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Java.Interop.TypeManager.n_Activate (System.IntPtr jnienv, System.IntPtr jclass, System.IntPtr typename_ptr, System.IntPtr signature_ptr, System.IntPtr jobject, System.IntPtr parameters_ptr) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: at Android.Runtime.DynamicMethodNameCounter.2 (System.IntPtr , System.IntPtr , System.IntPtr , System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <31a674ae732f498eaa71dc8ffa7c6f81>:0 monodroid-gref: handle 0x29e6; key_handle 0xc2ad59d: Java Type: `example/MainActivity`; MCW type: `HelloWorld.MainActivity` The new `gref+` and `lref+` log categories should not be considered to be "reliable"; message delivery is up to `adb logcat`, which has a known history of skipping messages. That said, this may be better than nothing, which was the previous alternative. [0]: https://developer.android.com/ndk/reference/group/logging#__android_log_print [1]: https://developer.android.com/guide/topics/manifest/application-element#debug
- Loading branch information