SuperSpaceEye / Some-Peripherals

MIT License
4 stars 4 forks source link

ConcurrentModificationException On Radar Scan #7

Closed 19PHOBOSS98 closed 11 months ago

19PHOBOSS98 commented 11 months ago

Hello! Does the Radar Block detect item entities and projectile entities as well?

This suddenly showed up when my guns were firing (all 16 of them):

2023-11-24_09 44 40

I think the radar had a hard time scanning all of the projectiles and dropped empty shell casings. The computercraft thread lagged a bit too when it happened. By "lag" I mean right-clicking on the terminal didn't take effect after a few minutes later...

maybe adding a filter mode for the radar.scan() function might help?

Found this in the logs too:

[24Nov2023 11:09:04.208] [ComputerCraft-Coroutine-3/ERROR] [computercraft/]: Error calling call on dan200.computercraft.core.apis.PeripheralAPI@3c97066a
java.util.ConcurrentModificationException: null
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013) ~[?:?]
    at java.util.ArrayList$Itr.next(ArrayList.java:967) ~[?:?]
    at com.google.common.collect.Iterators$1.next(Iterators.java:146) ~[guava-31.0.1-jre.jar%2330!/:?]
    at net.minecraft.world.level.entity.EntitySection.m_188352_(EntitySection.java:33) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.entity.EntitySectionStorage.m_188365_(EntitySectionStorage.java:118) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.entity.EntitySectionStorage.m_188362_(EntitySectionStorage.java:63) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.entity.EntitySectionStorage.m_156890_(EntitySectionStorage.java:118) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.entity.LevelEntityGetterAdapter.m_142232_(LevelEntityGetterAdapter.java:42) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.Level.m_6249_(Level.java:601) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.minecraft.world.level.EntityGetter.m_45933_(EntityGetter.java:33) ~[client-1.18.2-20220404.173914-srg.jar%23132!/:?]
    at net.spaceeye.someperipherals.utils.radar.ScanInRadiusKt.scanForEntities(ScanInRadiusKt.java:33) ~[Some-Peripherals-0.0.8.jar%23119!/:?]
    at net.spaceeye.someperipherals.utils.radar.ScanInRadiusKt.scanInRadius(ScanInRadiusKt.java:74) ~[Some-Peripherals-0.0.8.jar%23119!/:?]
    at net.spaceeye.someperipherals.integrations.cc.peripherals.RadarPeripheral.scan(RadarPeripheral.java:16) ~[Some-Peripherals-0.0.8.jar%23119!/:?]
    at net.spaceeye.someperipherals.integrations.cc.peripherals.RadarPeripheral$cc$scan138.apply(CC generated method) ~[?:?]
    at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral$RemotePeripheralWrapper.callMethod(WiredModemPeripheral.java:409) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral.callRemote(WiredModemPeripheral.java:212) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at dan200.computercraft.shared.peripheral.modem.wired.WiredModemPeripheral$cc$callRemote24.apply(CC generated method) ~[?:?]
    at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.call(PeripheralAPI.java:112) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at dan200.computercraft.core.apis.PeripheralAPI.call(PeripheralAPI.java:361) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at dan200.computercraft.core.apis.PeripheralAPI$cc$call102.apply(CC generated method) ~[?:?]
    at dan200.computercraft.core.lua.ResultInterpreterFunction.invoke(ResultInterpreterFunction.java:61) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.function.ResumableVarArgFunction.invoke(ResumableVarArgFunction.java:77) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.function.LuaInterpreter.execute(LuaInterpreter.java:506) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.function.LuaInterpretedFunction.resume(LuaInterpretedFunction.java:196) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.debug.DebugFrame.resume(DebugFrame.java:243) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.LuaThread.loop(LuaThread.java:570) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at cc.tweaked.internal.cobalt.LuaThread$1.run(LuaThread.java:466) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at dan200.computercraft.core.lua.CobaltLuaMachine.lambda$new$1(CobaltLuaMachine.java:80) ~[cc-tweaked-1.18.2-1.101.3.jar%2365!/:1.101.3]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
    at java.lang.Thread.run(Thread.java:833) [?:?]
SuperSpaceEye commented 11 months ago

Ok i think i know why this happens, but i will need to test it. How big was the radius?

SuperSpaceEye commented 11 months ago

I'm not sure i can do anything about the speed though :skull:

19PHOBOSS98 commented 11 months ago

Range was 500. It might help keep the scan table small if the scan function had a way to filter out projectiles and dropped items. Maybe even a way to filter out players and ships as well?

Tbh, I usually just need player and ship data for my stuff... AdvancedPeripheral had a separate block for scanning non player entities and that had a cooldown timer per scan...

Maybe having a separate scanning function for players, ships and entities might help minimize lag?

SuperSpaceEye commented 11 months ago

Hmmm... Alr I've looked at how AP looks for players, and I can implement something like that

SuperSpaceEye commented 11 months ago

Added timeout for entity scanning to prevent "lag", added 3 peripheral methods for separately scanning for ships, entities and players. Will be added in the next release.