v3rm0n / m8c-android

m8c for Android
MIT License
76 stars 4 forks source link

Not working on Pixel 6 #45

Open abayliss opened 1 year ago

abayliss commented 1 year ago

I'm having several issues getting this working on my Pixel 6 (on Android 13, fully up-to-date).

The app opens, I can connect to the Teensy and the display shows, but it only actually updates while I'm pressing a button. For example, if I press play, the waveform at the top shows, but then freezes. If I scroll around the interface, the waveform updates briefly as the cursor moves but then freezes again.

I've also not been able to get audio working at all, and I'm pretty sure I've tried all the available combinations of device and driver. I get no error messages, just no audio. When choosing the audio device, am I meant to be choosing the input device (the M8), or the output device? I get a list of 3 "Pixel 6" devices and one "USB-Audio - M8", although this last one only appears after I've connected to the M8 once, then closed and reopened the app.

v3rm0n commented 1 year ago

For screen issues you can try to press left and right buttons at the same time, it should reset the screen.

For audio issues you can try to disable audio routing and see if that helps https://mysupport.razer.com/app/answers/detail/a_id/1875/~/why-does-the-audio-come-out-from-the-speaker-and-not-routed-to-the-headset%3F

abayliss commented 1 year ago

Still no joy I'm afraid, although If I disable audio routing, and use the openslES driver I do get a regular clicking noise while the app is connected, but nothing like the audio I should be getting.

Pressing left and right at the same time has the same effect on the screen as any other button, as in, while I'm pressing them the screen refreshes briefly, but it freezes again straight away.

jasonjamesmoore commented 1 year ago

I am seeing the same issues as @abayliss on Pixel 6 Pro. Even if I never get it working, it's rad that you're doing this. Thanks!

cgxeiji commented 1 year ago

I have the same problem with v1.0.6, but with v1.0.5 the screen works great.

github-actions[bot] commented 1 year ago

Issue is marked as stale since there has been no activity for two weeks. It will be automatically closed in 5 days.

v3rm0n commented 1 year ago

Any changes in the latest release? https://github.com/v3rm0n/m8c-android/releases/tag/v1.0.17

viviicat commented 1 year ago

I'm also getting this on 6a. Same exact behavior.

I also cannot get audio to work. I have tried various combinations of audio settings and output devices and don't hear anything.

Also have the same screen refresh issues. No updates unless buttons are pressed which means the visualizer doesn't work.

cgxeiji commented 1 year ago

I just tried v1.0.17 and have the same problem. I noticed that the number of audio devices has diminished, but I cannot get the audio from M8.

github-actions[bot] commented 1 year ago

Issue is marked as stale since there has been no activity for two weeks. It will be automatically closed in 5 days.

v3rm0n commented 1 year ago

Just a heads up: I don't have a Pixel so it would be great if somebody else can look into it.

viviicat commented 1 year ago

This is something I had wanted to look into, but I haven't had a lot of free time lately.

v3rm0n commented 1 year ago

I actually managed to get into the same situation by putting the app in the background and resuming it so I refactored the code a bit to fix the resume issue, it might do something for the Pixel as well but probably not.

Just in case I also added a new Advanced setting in the preferences for Idle ms. You can try to change this value from the default of 0 to 1 or something else to see if it changes anything. Probably 10 is the highest value to go to.

https://github.com/v3rm0n/m8c-android/releases/tag/v1.0.24

viviicat commented 1 year ago

Not seeing any change with 6a and the new release. Fiddled with Idle ms and didn't notice much.

github-actions[bot] commented 1 year ago

Issue is marked as stale since there has been no activity for two weeks. It will be automatically closed in 5 days.

TheJoshuaByers commented 1 year ago

I'm on the Pixel 7 (Android 13) and running into the same issues described above. No screen refresh and no audio out.

Is there any way to share some debug logs?

TheJoshuaByers commented 1 year ago

Still not working with version 1.0.32 unfortunately. If there's anything I can do to help you debug, just send me a message! :)

KieranReck commented 11 months ago

Hi all, can confirm that im getting the same refresh and audio issues on a pixel 7a with v1.0.45.

Tis a shame, but I definitely can't complain with all the hard work that goes into any of this free community stuff!

viviicat commented 11 months ago

All right, I'm going to try to debug this this weekend. At least try to collate info. As I mentioned above, I have a phone that reproduces this.

viviicat commented 11 months ago

(i have an actual m8 and so i don't use headless much anymore, but I feel for folks who only have headless available!)

KieranReck commented 11 months ago

(i have an actual m8 and so i don't use headless much anymore, but I feel for folks who only have headless available!)

To be fair, there are so many options for M8 Headless that it isn't a game changing problem, but the android solution is by far the lowest component count of all the portable headless solutions so it is definitely appealing.

Here's some info on what I have tried so far:

So far, no changes.

The issues I see are the same as reported above, there is no audio, and the screen only refreshes upon a button press.

good luck!

cgxeiji commented 11 months ago

If you need any help debugging, I have a Pixel 7 Pro where I can test the app!

viviicat commented 11 months ago

Debugging, I'm hitting the "Buffer underflow" debug print in usb_audio.c (so, always -1 being returned from ring_buffer_pop), because the callback cb_xfr is not being hit. Audio driver does not seem to change this.

Here are the devices I have in the list (3 of them share the same name, which is messy):

Then, after a few seconds I hit a repeated breakpoint because it's receiving "SIGBUS" (illegal address). The stack trace for this appears to be inconsistent and also not user code, so I'm not sure how helpful it is (presumably the error is happening elsewhere and only manifesting later).

Maybe something like valgrind would catch the issue better, if that's something that can be done with Android/JNI.

viviicat commented 11 months ago

The SIGBUS error hits this stack initially:

art::StackVisitor::WalkStack<…>(bool) 0x000000764cdd1084
art::Thread::VisitRoots<…>(art::RootVisitor *) 0x000000764cdd0b00
art::gc::collector::MarkCompact::ThreadFlipVisitor::Run(art::Thread *) 0x000000764cefd2cc
art::Thread::RunFlipFunction(art::Thread *, bool) 0x000000764ccabfe8
art::ThreadList::FlipThreadRoots(art::Closure *, art::Closure *, art::gc::collector::GarbageCollector *, art::gc::GcPauseListener *) 0x000000764ccabcb0
art::gc::collector::MarkCompact::RunPhases() 0x000000764ce5c34c
art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool) 0x000000764cca31ec
art::gc::Heap::CollectGarbageInternal(art::gc::collector::GcType, art::gc::GcCause, bool, unsigned int) 0x000000764cc9f600
art::gc::Heap::ConcurrentGC(art::Thread *, art::gc::GcCause, bool, unsigned int) 0x000000764ce6f6e0
art::gc::Heap::ConcurrentGCTask::Run(art::Thread *) 0x000000764ce6f564
art::gc::TaskProcessor::RunAllTasks(art::Thread *) 0x000000764cda2b0c
art_quick_generic_jni_trampoline 0x000000764cd55834
art_quick_invoke_stub 0x000000764cd3eda8
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000764cf11054
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000764ce973e0
ExecuteSwitchImplAsm 0x000000764cd57fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000764cd74124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000764cf11d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000764ce973e0
ExecuteSwitchImplAsm 0x000000764cd57fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000764cd74124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000764cf11d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000764ce9828c
ExecuteSwitchImplAsm 0x000000764cd57fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000764cd74124
artQuickToInterpreterBridge 0x000000764cd73a1c
art_quick_to_interpreter_bridge 0x000000764cd5596c
art_quick_invoke_stub 0x000000764cd3eda8
art::ArtMethod::Invoke(art::Thread *, unsigned int *, unsigned int, art::JValue *, const char *) 0x000000764cc39d58
art::Thread::CreateCallback(void *) 0x000000764cf3a1b4
art::Thread::CreateCallbackWithUffdGc(void *) 0x000000764cf39b64
__pthread_start(void *) 0x00000078ef384cd0
__start_thread 0x00000078ef318b04

If I hit continue it hits this:

art::mirror::Object* art::gc::Heap::AllocObjectWithAllocator<true, true, art::mirror::String::AllocFromModifiedUtf8(art::Thread*, int, char const*, int)::$_0>(art::Thread*, art::ObjPtr<art::mirror::Class>, unsigned long, art::gc::AllocatorType, art::mirror::String::AllocFromModifiedUtf8(art::Thread*, int, char const*, int)::$_0 const&) (.__uniq.300758697700900032661301770954074801573.llvm.15993583663007277616) 0x000000764cc3d204
art::Thread::CreatePeer(const char *, bool, _jobject *) 0x000000764cdc5c50
art::Thread* art::Thread::Attach<art::Thread::Attach(char const*, bool, _jobject*, bool, bool)::$_0>(char const*, bool, art::Thread::Attach(char const*, bool, _jobject*, bool, bool)::$_0, bool) (.__uniq.112444171608964125319761912539055931073.llvm.12707530182260866679) 0x000000764cdc2d00
art::Runtime::AttachCurrentThread(const char *, bool, _jobject *, bool, bool) 0x000000764cdc2528
art::JII::AttachCurrentThreadInternal(_JavaVM *, _JNIEnv **, void *, bool) 0x000000764cef3288
art::(anonymous namespace)::CheckJII::AttachCurrentThread(_JavaVM*, _JNIEnv**, void*) (.__uniq.99033978352804627313491551960229047428.llvm.9379289081322328196) 0x000000764cccd85c
android::AndroidRuntime::javaThreadShell(void *) 0x00000078fbf02170
__pthread_start(void *) 0x00000078ef384cd0
__start_thread 0x00000078ef318b04
viviicat commented 11 months ago

https://github.com/laamaa/m8c/blob/9d70859ec2d75be67e2e80b04fb1f5b85b371737/src/usb_audio.c#L24 - here's the underflow bit I'm referring to, for reference.

viviicat commented 11 months ago

The return code of libusb_submit_transfer is -1 = LIBUSB_ERROR_IO - "Input/output error."

viviicat commented 11 months ago

I've instrumented libusb logging and have received the error message: libusb: error [submit_iso_transfer] submiturb failed, errno=95 errno 95 is: EOPNOTSUPP - Operation not supported on transport endpoint

viviicat commented 11 months ago

This might be related? https://github.com/libusb/libusb/pull/1164

TheJoshuaByers commented 10 months ago

@viviicat Thanks for diving into this. Looks like the issue lies in libusb compatibility with the Pixel?

v3rm0n commented 10 months ago

I think this PR will not make a difference since it's only about device discovery, which currently can only be done from JVM code. Just in case though I quickly threw together a version that uses this PR https://github.com/v3rm0n/m8c-android/actions/runs/7330220947

Try the artifact and see if there's any difference.

TheJoshuaByers commented 10 months ago

@v3rm0n Thanks for the build! The UI now refreshes like it should (v47 still does not refresh). Unfortunately, I'm getting no audio. I've tried all combinations of audio drivers and interfaces. It would be great if someone could confirm this so we know it's not user error.

viviicat commented 10 months ago

I won't be able to verify this until next week myself, as i am away from my teensy

KieranReck commented 10 months ago

Tested v48 on my Pixel 7a today, I found that the screen refresh was still a problem. One time when I loaded the app up the screen refreshed very intermittently, but after that time I was never able to recreate this, it simply wouldnt refresh without a button press.

Audio still appears not to be working

nrichards commented 10 months ago

Tested v48 on my Pixel 7a today, I found that the screen refresh was still a problem. One time when I loaded the app up the screen refreshed very intermittently, but after that time I was never able to recreate this, it simply wouldnt refresh without a button press.

Audio still appears not to be working

+1 here on Pixel Fold (similar generation to 7a) using v48 - no audio.

Also, I no longer see "m8" USB audio device option (only 2x "Pixel Fold" devices) - I did before (with https://github.com/v3rm0n/m8c-android/issues/45#issuecomment-1869588666), and speculate my phone is the cause since the v48 binary is the same as the artifact from your comment earlier.

I set up wireless debugging in Android Studio and saw a couple messages. I ran main 802c024, managed to attach & debug, watched logcat, and saw the following warnings:

...
2024-01-01 17:44:27.364 17666-18260 hidapi                  io.maido.m8client                    E  hid_init threw an exception: io.maido.m8client: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
...
2024-01-01 17:44:27.668 17666-18260 BLASTBufferQueue        io.maido.m8client                    E  [SurfaceView[io.maido.m8client/io.maido.m8client.M8SDLActivity]#12](f:0,a:0) rejecting buffer:active_size=2208x1656, requested_size=2208x1656 buffer{size=1646x2194 transform=7}
2024-01-01 17:44:27.670 17666-18260 SDL/ERROR               io.maido.m8client                    E  Invalid draw character packet: expected length 12, got 9
...
2024-01-01 17:44:42.464 17666-18260 .maido.m8client         io.maido.m8client                    E  PIXEL: ioctl err: 1

m8c-android_issues_45-pixelfold_logcat.txt

UPDATE: I see Auto Screen Refresh of the headless m8 now, after I 1) manually launch, 2) attach and debug, then 3) detach .. via stop (just the Java side, I believe, not the Native process). Re-attaching keeps the Auto Refresh going. I estimate FPS to be between 0.5 and 4.

wangel13 commented 8 months ago

I checked on s23 ultra, everything works fine except audio. m8c@v1.0.56 and M8_V3_2_7_HEADLESS used.

wangel13 commented 7 months ago

Checked again, audio working! Just need to change audio input.