Android Question Got a Pixel phone + usb connection + Android 16?

Sandman

Expert
Licensed User
Longtime User
There's two of us with that combination here in the forum that started getting "AppName isn't responding" messages.

If you are have the combination above, could you please comment on whether you get these messages now and then?
(Also post if you have the combination and do not get the messages.)


If you want to read more about this issue, here is the thread:
www.b4x.com/android/forum/threads/appname-not-responding.170706/
 

Sandman

Expert
Licensed User
Longtime User
Please post the logs when it happens.
Ok, I got an ANR again.

This is what happened:

1. I connected my phone to USB
2. I compiled as Debug
3. The screen on my phone went white, and nothing happened
4. The IDE informed me that it couldn't connect the debugger

...the steps above are well known to me, they happen often when I connect my phone via USB. The first compile almost always fails with this message. My mental model for explaining this is simply "I disconnected the phone rudely so something was probably still in there, in some half-working state". This is very well known behaviour for me so I simply continue...

5. I compile as Debug again
6. The app launches like it's supposed to
7. I didn't do anything for about 20 seconds
8. "App isn't responding" message on phone

I dumped both the log and the anr file and sent to support@basic4ppc.com.

Update. I disconnected the phone and did something else for a while. Connected it again and did the above steps - with the exact same result, including the ANR. So that could be an indication and perhaps clue to what is happening.

Update 2. I disconnected the phone and did something else for a while. Connected it again and did the above steps. This time I didn't get the white screen and the IDE message about it couldn't connect to the debugger. I also didn't get an ANR message.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thanks @Sandman.

It is still not clear why it fails to start the service properly. Please make a test and remove the starter service completely and see whether the ANR is solved. There are still some usages for the starter service such as Application_Error, but it looks like it makes sense to provide whatever possible in different modules and remove it by default.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Please make a test and remove the starter service completely and see whether the ANR is solved.
Ok, will do. However, I'll start by keeping a closer eye on when the ANRs happen in the next few days. I just want to check if I ever get an ANR without the IDE failing to connect the debug process just before. After that I'll remove the Starter. I expect to report back here next week.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I think I already have enough information to give an update.

First of all, when I have Starter in the project, this is a more correct description of what happens when I get the ANRs:

1. I connected my phone to USB
2. I compiled as Debug
3. The screen on my phone went white, and nothing happened
4. The IDE informed me that it couldn't connect the debugger
5. I didn't do anything for about 20 seconds
6. "App isn't responding" message on phone

(In #21, above, I describe how I get the message when doing a second compile. But when I stopped rushing the second compile and instead just waited, I realized that the ANR is related to the first compile.)


I then tried removing Starter to see what would happen. Several tries in and this is it:

1. I connected my phone to USB
2. I compiled as Debug
3. The screen on my phone shows gray background, with a message "Waiting for IDE debugger to connect" (can't remember seeing that before, because Starter is gone?)
4. The IDE informed me that it couldn't connect the debugger
5. I didn't do anything for about 20 seconds
6. The message on the phone goes away and I return to the "Desktop"
7. No ANR


For both these scenarios, if I compile debug again, the IDE instantly connects and everything works just as expected.

I've done a lot more tests as I've tried to find a common thread for what is going on. I haven't quite finally found one, but I have found one thing that surprised me: If I have a (working) debug running and press Stop in the IDE the app stops. I then disconnect the phone and reconnect it. (Remember: USB) Then I compile debug again, and it will still fail most of the times. (Like I said, no common thread - it doesn't always fail.) It surprised me because I thought that me just pulling the cord while the debug app was running left it in some half-working state that messed with the next compilation - doesn't seem to be correct at all.

In any case there might be a root cause for all this - that the IDE and the debug app can't establish a connection under some (for me) unknown circumstances.


There are still some usages for the starter service such as Application_Error, but it looks like it makes sense to provide whatever possible in different modules and remove it by default.
From my perspective it makes a lot of sense to have Application_Error in Main.

Update. I forgot to mention that if I see that the connection takes too long to establish I can just press stop and compile again, and it works pretty much instantly. (Meaning I don't have to wait for any error messages.)
 
Last edited:
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Erel: I just got a notification that my Pixel have an OS update available. Would you like me to update and see if I see any difference, or would you prefer I stay on this version for a while so I can run some tests for you?
 
Upvote 0

LucasHeer

Active Member
Licensed User
Longtime User
Erel: I just got a notification that my Pixel have an OS update available. Would you like me to update and see if I see any difference, or would you prefer I stay on this version for a while so I can run some tests for you?
I am unsure if it is related to your issue, but this newest pixel update has 100% solved my random crashes and "App Not Responding" issues. I wish Google were more verbose about what they are doing
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I am unsure if it is related to your issue, but this newest pixel update has 100% solved my random crashes and "App Not Responding" issues.
That sounds promising, thanks for the feedback. However, I'll hold off for a while to see what Erel says. After all, there is a tiny chance that there might be an issue somewhere in B4A and this might be a (somewhat) good possibility to fix it. We'll see what he says.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Another small datapoint to nuance things.

I had my phone plugged in, stopped the (debug) app, adjusted some code and ran compiled it again (debug). The IDE failed to connect and the mobile gave me the ANR shortly after. So this doesn't only happen when I have just connected the phone with USB, it can apparently also happen when it has been connected for some time.

This is the log in the IDE when it failed to connect:
B4X:
java.lang.RuntimeException: java.net.SocketException: Socket closed
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:105)
    at b4a.example.main.afterFirstLayout(main.java:97)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:1095)
    at android.os.Handler.dispatchMessageImpl(Handler.java:135)
    at android.os.Handler.dispatchMessage(Handler.java:125)
    at android.os.Looper.loopOnce(Looper.java:269)
    at android.os.Looper.loop(Looper.java:367)
    at android.app.ActivityThread.main(ActivityThread.java:9333)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
Caused by: java.net.SocketException: Socket closed
    at java.net.SocketInputStream.read(SocketInputStream.java:188)
    at java.net.SocketInputStream.read(SocketInputStream.java:143)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:239)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:279)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:338)
    at java.io.DataInputStream.readFully(DataInputStream.java:203)
    at java.io.DataInputStream.readInt(DataInputStream.java:394)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
    ... 14 more
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Worth updating.
I updated and tried a project with Starter, and no StopService(me) in Service_Create. Got ANR just as before.

However, with the StopService(me) in Service_Create workaround it works well enough for me that I don't find this a priority. I mean, I can Debug with it, and you seem to about to move Application_Error somewhere else entirely so Starter might be a thing of the past anyway.
 
Upvote 0
Top