billthefarmer / mididriver

Android midi driver using Sonivox EAS library
176 stars 52 forks source link

Infinitely building reverb-like echo noise on Galaxy S-6 following playing of chord #24

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi billthefarmer.

First of all, thank you so much for writing this useful driver - I appreciate your work very much!

I've upgraded to v1.11, referenced in Gradle via "compile 'com.github.billthefarmer:mididriver:v1.11'".

Proir to this I was using the previous version, stored locally, and referenced in Gradle via: "compile project(':MidiDriver-all-release')" which resolved to the local file "MidiDriver-all-release.aar".

While testing the new version v1.11 by running your "miditest", I encountered an aberration running on a Galaxy S-6 with the following specs:

  Model: SAMSUNG-SM-G890A
  Android Version 5.1.1
  Kernel Version: 3.10.61-7277676

When I quickly press and release the "C chord" button, the chord briefly sounds but then a low reverb-like echoing noise starts, rapidly becoming louder until distorted, and continues indefinitely until I switch away from the app.

This was not present in the old driver.

In the notes for the v1.11 release I see you state that Google fixed a "64 bit reverb bug". The description "reverb bug" seems like it might refer to what I am experiencing, but since this has been fixed, I am not sure if the problem is with the S-6, the Android OS it has installed, or the Midi Driver.

What do you think?

I ran the Midi Test on the S-6 using the old driver (no infinite reverb echo noise) and using the new v1.11 driver (infinite reverb echo noise) with a log level of VERBOSE and have included the output here in case this is helpful to you:

********** OLD DRIVER (no issues, using local file "MidiDriver-all-release.aar")
04-01 19:49:57.999 2566-2566/? E/Zygote: MountEmulatedStorage()
04-01 19:49:57.999 2566-2566/? E/Zygote: v2
04-01 19:49:57.999 2566-2566/? I/libpersona: KNOX_SDCARD checking this for 10239
04-01 19:49:57.999 2566-2566/? I/libpersona: KNOX_SDCARD not a persona
04-01 19:49:57.999 2566-2566/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SAMSUNG-SM-G890A_5.1.1_0046
04-01 19:49:57.999 2566-2566/? E/Zygote: accessInfo : 0
04-01 19:49:57.999 2566-2566/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-01 19:49:57.999 2566-2566/? I/art: Late-enabling -Xcheck:jni
04-01 19:49:58.009 2566-2566/? D/TimaKeyStoreProvider: TimaSignature is unavailable
04-01 19:49:58.009 2566-2566/? D/ActivityThread: Added TimaKeyStore provider
04-01 19:49:58.029 2566-2566/? I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
04-01 19:49:58.029 2566-2566/? I/InjectionManager: Inside getClassLibPath caller 
04-01 19:49:58.029 2566-2566/? D/InjectionManager: InjectionManager
04-01 19:49:58.029 2566-2566/? D/InjectionManager: fillFeatureStoreMap org.billthefarmer.miditest
04-01 19:49:58.029 2566-2566/? I/InjectionManager: Constructor org.billthefarmer.miditest, Feature store :{}
04-01 19:49:58.029 2566-2566/? I/InjectionManager: featureStore :{}
04-01 19:49:58.029 2566-2573/? E/art: Failed sending reply to debugger: Broken pipe
04-01 19:49:58.029 2566-2573/? I/art: Debugger is no longer active
04-01 19:49:58.039 2566-2566/? D/SecWifiDisplayUtil: Metadata value : SecSettings2
04-01 19:49:58.059 2566-2566/? D/PhoneWindow: *FMB* installDecor mIsFloating : false
04-01 19:49:58.059 2566-2566/? D/PhoneWindow: *FMB* installDecor flags : 8454400
04-01 19:49:58.069 2566-2566/? I/MidiDriver: Init function called
04-01 19:49:58.069 2566-2566/? I/MidiDriver: dlopen libsonivox.so passed
04-01 19:49:58.069 2566-2566/? I/MidiDriver: Init function passed
04-01 19:49:58.069 2566-2566/? D/Activity: performCreate Call Injection manager
04-01 19:49:58.069 2566-2566/? I/InjectionManager: dispatchOnViewCreated > Target : org.billthefarmer.miditest.MainActivity isFragment :false
04-01 19:49:58.079 2566-2566/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
04-01 19:49:58.089 2566-2583/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-01 19:49:58.099 2566-2566/? D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
04-01 19:49:58.099 2566-2566/? D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
04-01 19:49:58.109 2566-2566/? D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 
04-01 19:49:58.129 2566-2583/? D/libEGL: loaded /vendor/lib/egl/libGLES_mali.so
04-01 19:49:58.149 2566-2583/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-01 19:49:58.149 2566-2583/? I/OpenGLRenderer: HWUI protection enabled for context ,  &this =0xeedd5c10 ,&mEglDisplay = 1 , &mEglConfig = -287329636 
04-01 19:49:58.149 2566-2583/? D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
04-01 19:49:58.149 2566-2583/? D/OpenGLRenderer: Enabling debug mode 0
04-01 19:49:58.149 2566-2583/? D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
04-01 19:49:58.159 2566-2566/? I/InjectionManager: dispatchCreateOptionsMenu :org.billthefarmer.miditest.MainActivity
04-01 19:49:58.159 2566-2566/? I/InjectionManager: dispatchPrepareOptionsMenu :org.billthefarmer.miditest.MainActivity
04-01 19:49:58.259 2566-2566/? I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f548514 time:2812750
04-01 19:50:01.469 2566-2566/org.billthefarmer.miditest D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN

********** NEW DRIVER (infinite reverb echo noise, using remote file "compile 'com.github.billthefarmer:mididriver:v1.11'")
04-01 19:51:03.369 3232-3232/? E/Zygote: MountEmulatedStorage()
04-01 19:51:03.369 3232-3232/? E/Zygote: v2
04-01 19:51:03.369 3232-3232/? I/libpersona: KNOX_SDCARD checking this for 10239
04-01 19:51:03.369 3232-3232/? I/libpersona: KNOX_SDCARD not a persona
04-01 19:51:03.369 3232-3232/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SAMSUNG-SM-G890A_5.1.1_0046
04-01 19:51:03.369 3232-3232/? E/Zygote: accessInfo : 0
04-01 19:51:03.369 3232-3232/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-01 19:51:03.369 3232-3232/? I/art: Late-enabling -Xcheck:jni
04-01 19:51:03.389 3232-3232/? D/TimaKeyStoreProvider: TimaSignature is unavailable
04-01 19:51:03.389 3232-3232/? D/ActivityThread: Added TimaKeyStore provider
04-01 19:51:03.429 3232-3232/org.billthefarmer.miditest I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
04-01 19:51:03.429 3232-3232/org.billthefarmer.miditest I/InjectionManager: Inside getClassLibPath caller 
04-01 19:51:03.439 3232-3232/org.billthefarmer.miditest D/InjectionManager: InjectionManager
04-01 19:51:03.439 3232-3232/org.billthefarmer.miditest D/InjectionManager: fillFeatureStoreMap org.billthefarmer.miditest
04-01 19:51:03.439 3232-3232/org.billthefarmer.miditest I/InjectionManager: Constructor org.billthefarmer.miditest, Feature store :{}
04-01 19:51:03.439 3232-3232/org.billthefarmer.miditest I/InjectionManager: featureStore :{}
04-01 19:51:03.439 3232-3232/org.billthefarmer.miditest D/SecWifiDisplayUtil: Metadata value : SecSettings2
04-01 19:51:03.469 3232-3232/org.billthefarmer.miditest D/PhoneWindow: *FMB* installDecor mIsFloating : false
04-01 19:51:03.469 3232-3232/org.billthefarmer.miditest D/PhoneWindow: *FMB* installDecor flags : 8454400
04-01 19:51:03.489 3232-3232/org.billthefarmer.miditest D/Activity: performCreate Call Injection manager
04-01 19:51:03.489 3232-3232/org.billthefarmer.miditest I/InjectionManager: dispatchOnViewCreated > Target : org.billthefarmer.miditest.MainActivity isFragment :false
04-01 19:51:03.499 3232-3232/org.billthefarmer.miditest W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
04-01 19:51:03.519 3232-3308/org.billthefarmer.miditest D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-01 19:51:03.529 3232-3232/org.billthefarmer.miditest D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
04-01 19:51:03.529 3232-3232/org.billthefarmer.miditest D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
04-01 19:51:03.539 3232-3232/org.billthefarmer.miditest D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 
04-01 19:51:03.579 3232-3308/org.billthefarmer.miditest D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
04-01 19:51:03.599 3232-3308/org.billthefarmer.miditest I/OpenGLRenderer: Initialized EGL, version 1.4
04-01 19:51:03.609 3232-3308/org.billthefarmer.miditest I/OpenGLRenderer: HWUI protection enabled for context ,  &this =0x7f89c1ea40 ,&mEglDisplay = 1 , &mEglConfig = -1982856528 
04-01 19:51:03.609 3232-3308/org.billthefarmer.miditest D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
04-01 19:51:03.609 3232-3308/org.billthefarmer.miditest D/OpenGLRenderer: Enabling debug mode 0
04-01 19:51:03.609 3232-3308/org.billthefarmer.miditest D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
04-01 19:51:03.609 3232-3232/org.billthefarmer.miditest I/InjectionManager: dispatchCreateOptionsMenu :org.billthefarmer.miditest.MainActivity
04-01 19:51:03.609 3232-3232/org.billthefarmer.miditest I/InjectionManager: dispatchPrepareOptionsMenu :org.billthefarmer.miditest.MainActivity
04-01 19:51:03.659 3232-3308/org.billthefarmer.miditest E/BlobCache: unflatten: not enough room for cache entry headers
04-01 19:51:03.659 3232-3308/org.billthefarmer.miditest E/libEGL: error reading cache contents: Invalid argument (22)
04-01 19:51:03.749 3232-3232/org.billthefarmer.miditest I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f548514 time:2878247
04-01 19:51:17.959 3232-3232/org.billthefarmer.miditest D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN

Thank you for your time and help.

Rodney Ryan

ghost commented 7 years ago

I just read your response to issue #14 "Endless echo using MIDI playback on Nexus 9 5.x".

You state the fix is to not build/remove the 64 bit libraries, but I'm not sure how to do this.

Would this be the fix, then? If so, how would I execute it?

ghost commented 7 years ago

I just read your response to issue #11 "Noise on android lollipop 5.1+".

There you say a solution is to use 7z to remove the 64-bit files from the APK. If this is the solution here, is there a way to do this with the files that Gradle downloads for the v1.11 dependency, instead of removing them from the APK?

However, that issue is almost two years ago, prior to the v1.11 release, so perhaps the advice given there is no longer relevant...?

billthefarmer commented 7 years ago

It looks like your device is using the broken built in 64 bit library rather than the fixed one provided in the driver. I have changed the name of the sonivox library in the driver so this is no longer possible.

ghost commented 7 years ago

Thank you for your prompt turnaround. v1.12 solves this Galaxy S-6 issue.

A new issue has appeared with v1.12 on a Nexus Galaxy II running 4.1.2 (API 16). Here is the relevant log output from your MidiTest app:

From Nexus Galaxy II running 4.1.2 (API 16) [mididdriver v.1.12] executing "MidiTest"

04-06 17:38:34.544 17526-17526/? D/dalvikvm: Trying to load lib /data/data/org.billthefarmer.miditest/lib/libmidi.so 0x41ffcf80
04-06 17:38:34.544 17526-17526/? W/dalvikvm: Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/billthefarmer/mididriver/MidiDriver;
04-06 17:38:34.549 17526-17526/? D/AndroidRuntime: Shutting down VM
04-06 17:38:34.549 17526-17526/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x415af2a0)
04-06 17:38:34.549 17526-17526/org.billthefarmer.miditest E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
    at org.billthefarmer.miditest.MainActivity.onCreate(MainActivity.java:68)
    at android.app.Activity.performCreate(Activity.java:5206)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
    at android.app.ActivityThread.access$700(ActivityThread.java:140)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4921)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1892]:  1825 could not load needed library 'libsynth.so' for 'libmidi.so' (load_library[1094]: Library 'libsynth.so' not found)
    at java.lang.Runtime.loadLibrary(Runtime.java:370)
    at java.lang.System.loadLibrary(System.java:535)
    at org.billthefarmer.mididriver.MidiDriver.<clinit>(MidiDriver.java:102)
    at org.billthefarmer.miditest.MainActivity.onCreate(MainActivity.java:68) 
    at android.app.Activity.performCreate(Activity.java:5206) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
    at android.app.ActivityThread.access$700(ActivityThread.java:140) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:4921) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) 
    at dalvik.system.NativeStart.main(Native Method)
billthefarmer commented 7 years ago

It looks like I can't win. Devices running 4.2.2 (API 17) and below can't load a second native library unless it's built in. Devices running 7.0 (API 24) and above don't allow the use of unsupported built in native libraries. Devices running 64 bit 5.01 or 5.1.1 may have a broken 64 bit version of the sonivox native library and will use the broken built in version rather then the fixed version in the driver. It looks like the only solution that will work on all devices is to not rename the sonivox library and only provide a 32 bit version of the driver.

ghost commented 7 years ago

What would be the downside if I use only the 32-bit drivers without the renamed sonivox library?

From what you wrote above, it seems the other solution is to use the current v1.12 and increase my min SDK version from 15 to 18. From the Android Dashboards stats and several other places I googled today a min SDK version of 18 still represents 90% of the devices out there. Do you feel it would be worth it to move to a min SDK of 18 in order to use the 64-bit drivers in their current configuration?

ghost commented 7 years ago

I examined the releases and it looks like 1.08 is 32-bit only. I did some testing with versions 1.08, 1.11, and 1.12, and 1.08 worked in all circumstances. It seems I would be able to use the version 1.08 32-bit only driver without experiencing any drawbacks (except the loss of improvements in future releases, unless there is a way to remove the 64-bit drivers from the releases?).

Does this match your expectation or am I missing something?

In case you find it helpful here are the testing details.

G: means Google Pre-launch test. D: means I tested it on that device.

Device and Version v1.08 - 32 bit v1.11 - 64 bit v1.12 - fix for (1)
Emulator (7.1.1 - 25) - - -
G: Moto G 2nd Gen (4.4 - 19) - - -
G: zeroflte (5.1 - 22) - - -
G: Moto G 1st Gen (4.4 - 19) ? - -
G: Moto X 2nd Gen (4.4 - 19) - - -
G: LG G3 (4.4 - 19) ? - -
G: Nexus 5 (4.4 - 19) - - -
G: Nexus 5 (5.1 - 22) - - -
G: HTC One (M8) (4.4 - 19) - - -
G: Nexus 7 (5.0 - 21) - - -
G: Nexus 9 (5.0 - 21) - - -
G: Galaxy Note3 (4.4 - 19) - - -
D: Moto E (5.1 - 22) - - -
D: Galaxy II (4.1.2 - 16) - - (2)
D: Galaxy III (4.4.2 - 19) - - -
D: Galaxy S4 mini (4.4.2 - 19) - - -
D: Galaxy S5 (5.0 - 21) - - -
D: Galaxy S6 (5.1.1 - 22) - (1) -
D: Alcatel 4060A (5.1.1 - 22) - - -
D: 7" Galaxy (4.4.4 - 19) - - -
D: 10" Insignia (6.0.1 - 23) - - -

? = Device not available for testing at the time.

(1) = Uses broken built in 64-bit library, generates reverb noise.

(2) = UnsatisfiedLinkError: could not load needed library 'libsynth.so' for 'libmidi.so' (load_library[1094]: Library 'libsynth.so' not found)

billthefarmer commented 7 years ago

Version 1.08 is 32 bit only, so should be ok. I have uploaded 32 bit versions of version 1.11 and 1.12. The only change in 1.12 was to rename the sonivox library which caused link errors in older versions of android. I am working on getting Gradle to build 32 bit native libraries only so JitPack will work for all devices.

billthefarmer commented 7 years ago

I have pushed a new 32 bit only version which should work fine via JitPack .

ghost commented 7 years ago

Yes, v1.13 via JitPack works on all devices. Thank you very much for your prompt responses and quick turnaround time - I really appreciate it!