Bug 446599 - Android app crashes OOM at org.kde.kdeconnect.NetworkPacket.serialize(NetworkPacket.java:246)
Summary: Android app crashes OOM at org.kde.kdeconnect.NetworkPacket.serialize(Network...
Status: REPORTED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (other bugs)
Version First Reported In: 1.10
Platform: Android Android 8.x
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-07 01:56 UTC by Ben Brian
Modified: 2023-04-01 09:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Brian 2021-12-07 01:56:30 UTC
SUMMARY
12-06 20:37:55.692  8372  8846 I zygote  : Alloc concurrent copying GC freed 751(78KB) AllocSpace objects, 1(16KB) LOS objects, 14% free, 141MB/165MB, paused 182us total 333.104ms
12-06 20:37:55.692  8372  8846 I zygote  : Forcing collection of SoftReferences for 144MB allocation
12-06 20:37:55.692  8372  8846 I zygote  : Starting a blocking GC Alloc
12-06 20:37:55.863  8372  8845 E CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 2 rows, 8 columns.
12-06 20:37:55.863  8372  8845 E CursorWindow: Failed to read row 1, column -1 from a CursorWindow which has 2 rows, 8 columns.
12-06 20:37:56.138  8372  8845 E CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 2 rows, 8 columns.
12-06 20:37:56.138  8372  8845 E CursorWindow: Failed to read row 1, column -1 from a CursorWindow which has 2 rows, 8 columns.
12-06 20:37:56.198  8372  8846 I zygote  : Alloc concurrent copying GC freed 951(60KB) AllocSpace objects, 0(0B) LOS objects, 14% free, 141MB/165MB, paused 179us total 506.103ms
12-06 20:37:56.198  8372  8846 W zygote  : Throwing OutOfMemoryError "Failed to allocate a 150994952 byte allocation with 25165824 free bytes and 50MB until OOM, max allowed footprint 173877416, growth limit 201326592"
--------- beginning of crash
12-06 20:37:56.207  8372  8846 E AndroidRuntime: FATAL EXCEPTION: Thread-20
12-06 20:37:56.207  8372  8846 E AndroidRuntime: Process: org.kde.kdeconnect_tp, PID: 8372
12-06 20:37:56.207  8372  8846 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 150994952 byte allocation with 25165824 free bytes and 50MB until OOM, max allowed footprint 173877416, growth limit 201326592
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at java.util.Arrays.copyOf(Arrays.java:3260)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:125)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:660)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at java.lang.StringBuilder.append(StringBuilder.java:203)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.string(JSONStringer.java:344)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:252)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONObject.writeTo(JSONObject.java:723)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:237)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONArray.writeTo(JSONArray.java:613)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:233)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONObject.writeTo(JSONObject.java:723)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:237)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONArray.writeTo(JSONArray.java:613)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:233)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONObject.writeTo(JSONObject.java:723)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONStringer.value(JSONStringer.java:237)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONObject.writeTo(JSONObject.java:723)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.json.JSONObject.toString(JSONObject.java:692)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.kde.kdeconnect.NetworkPacket.serialize(NetworkPacket.java:246)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.kde.kdeconnect.Backends.LanBackend.LanLink.sendPacket(LanLink.java:158)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.kde.kdeconnect.Device.sendPacketBlocking(Device.java:700)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at org.kde.kdeconnect.DevicePacketQueue$SendingThread.run(DevicePacketQueue.java:107)
12-06 20:37:56.207  8372  8846 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)



STEPS TO REPRODUCE
1. Run KDEConnect on mobile device.
2. Run GSConnect on paired device.
3. Wait or use system normally (in my case about 5-10min); no need to directly interact with GS/KDEConnect.

OBSERVED RESULT
Android app crashes with standard message: "KDE Connect has stopped." Happens very reliably.

EXPECTED RESULT
App continues to run correctly in the background.

SOFTWARE/OS VERSIONS
Paired host: GSConnect 47 on Fedora 35
KDEConnect mobile: KDEConnect 1.18.1 (f-droid) on Android 8.1.0

ADDITIONAL INFORMATION
Comment 1 Albert Vaca Cintora 2023-04-01 09:30:01 UTC
144MB for a network packet is not normal, but we can't know which plugin tried to send that just by looking at the stack trace. Is this happening consistently?
Comment 2 Albert Vaca Cintora 2023-04-01 09:35:28 UTC
Maybe it happens when sending contacts? We base64 encode the contacts' profile pictures and send them as a string in a network packet [1], but if you have used some big images as your contacts' pictures they can be a few MB each... multiply that by a few contacts and (it's hard but) it could add to a hundred MB.

[1] https://invent.kde.org/network/kdeconnect-android/-/blob/0f4643e5/src/org/kde/kdeconnect/Helpers/ContactsHelper.java#L73-88
Comment 3 Albert Vaca Cintora 2023-04-01 09:36:11 UTC
In any case, it would be super helpful if we could somehow see in the stacktrace which plugin really caused the crash, which we cannot at the moment. Otherwise we are just speculating.