这是indexloc提供的服务,不要输入任何密码
Skip to content

Concurrent modification exception when creating activities after closing 3 others #64

@oli-obk

Description

@oli-obk

I had several activities that were each created one after the other. I closed multiple of them by pressing the back button (soft key) a few times in succession, then pressed a button in the activity that I was then in to open a new activity. I don't even get a response from termux-gui, the sockets close immediately.

I cannot reproduce with just two activities closed, it must be three. Which may just be random, but that's why the repro (at the bottom) has 3 activities

logcat output of the crash. Corresponding events and messages sent follow below

01-01 16:27:50.225 10438 10438 W WindowOnBackDispatcher: sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda17@b99268d
01-01 16:27:50.765 10438 10438 W WindowOnBackDispatcher: sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda17@ac62a5d
01-01 16:27:50.933 10438 19136 W System.err: java.util.ConcurrentModificationException
01-01 16:27:50.933 10438 19136 W System.err: 	at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:977)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.util.LinkedList$ListItr.next(LinkedList.java:899)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.json.v0.V0Json.handleActivity(V0Json.kt:19)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.json.v0.V0Json.access$handleActivity(V0Json.kt:1)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.json.v0.V0Json$handleConnection$1.invoke(V0Json.kt:20)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.json.v0.V0Json$handleConnection$1.invoke(V0Json.kt:1)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.shared.v0.V0Shared.withSystemListenersAndCleanup(V0Shared.kt:119)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.protocol.json.v0.V0Json.handleConnection(V0Json.kt:68)
01-01 16:27:50.934 10438 19136 W System.err: 	at com.termux.gui.ConnectionHandler.run(ConnectionHandler.kt:354)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
01-01 16:27:50.934 10438 19136 W System.err: 	at java.lang.Thread.run(Thread.java:1012)

Events are preparsed, i'll create some logging to dump the json instead. Messages are the raw json that I sent

Activity { aid: 2, finishing: false, kind: Stop }
Activity { aid: 3, finishing: true, kind: Pause }
Activity { aid: 2, finishing: false, kind: Start }
Activity { aid: 2, finishing: false, kind: Resume }
Activity { aid: 2, finishing: true, kind: Pause }
Activity { aid: 1, finishing: false, kind: Start }
Activity { aid: 1, finishing: false, kind: Resume }
Activity { aid: 3, finishing: true, kind: Stop }
Activity { aid: 1, finishing: true, kind: Pause }
Activity { aid: 0, finishing: false, kind: Start }
Activity { aid: 0, finishing: false, kind: Resume }
Activity { aid: 2, finishing: true, kind: Stop }
Activity { aid: 1, finishing: true, kind: Stop }
{"method":"newActivity","params":{"dialog":false,"pip":false,"cancel_outside":false,"lock_screen":false,"overlay":false}}

Python repro. Press the back soft key three times and then press the button. You may have to enter Ctrl + C to show the actual error.

File "/data/data/com.termux/files/home/repro.py", line 14, in <module>
    tg.Activity(c)
  File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/termuxgui/activity.py", line 29, in __init__
    self.aid, tid = self.c.send_read_msg({"method": "newActivity", "params": params})                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
import termuxgui as tg
import termuxgui.msg as tgmsg
import sys

with tg.Connection() as c:
    a = tg.Activity(c)
    button = tg.Button(a, "boom")
    b = tg.Activity(c)
    d = tg.Activity(c)
    e = tg.Activity(c)
    for ev in c.events():
        if ev.type == tg.Event.click:
            tg.Activity(c)
            sys.exit()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions