petertalbanese / SoundSwapper

Allows the user to replace sounds with custom .wav files.
BSD 2-Clause "Simplified" License
1 stars 4 forks source link

AssertionError on profile change. #16

Closed geheur closed 1 year ago

geheur commented 1 year ago
java.lang.AssertionError: must be called on client thread
    at client.setGameState(client.java:51244)
    at com.soundswapper.SoundSwapperPlugin.onConfigChanged(SoundSwapperPlugin.java:175)
    at net.runelite.client.eventbus.EventBus$Subscriber.invoke(EventBus.java:70)
    at net.runelite.client.eventbus.EventBus.post(EventBus.java:223)
    at net.runelite.client.config.ConfigManager.switchProfile(ConfigManager.java:234)
    at net.runelite.client.plugins.config.ProfilePanel.lambda$switchToProfile$7(ProfilePanel.java:666)
    at net.runelite.client.util.RunnableExceptionLogger.run(RunnableExceptionLogger.java:41)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

configchanged can happen on any thread, so you should probably wrap it in clienthtread.invokelater.

This is an error not an exception so it isn't caught and cuts the profile change short with assertions enabled which makes working on my plugin hub plugins harder :P

petertalbanese commented 1 year ago

I think this only matters for the setGameState() call, right? So if I wrap it like:

clientThread.invokeLater(() ->
{
    client.setGameState(GameState.LOADING);
});

Should solve the issue?

geheur commented 1 year ago

I'd expect that would work. Thanks for looking at this <3.

petertalbanese commented 1 year ago

Hopefully this should do it: https://github.com/petertalbanese/SoundSwapper/pull/17

Np, thanks for the report!