Skip to content

Conversation

@SirYwell
Copy link
Contributor

Fixes #543

Spark reads null as the game thread at the point of initialization. I wasn't able to really figure out why that changed with 1.21.11, but given how the information is used, it makes sense to just use a supplier directly and access the game thread when needed.

Tested on Fabric for 1.21.11.

@lucko lucko merged commit cbba1a1 into lucko:master Dec 28, 2025
3 checks passed
@SirYwell SirYwell deleted the fix/lazy-get-game-thread branch December 28, 2025 18:39
@TheDGOfficial
Copy link

I've had this happen in 1.21.10 as well today, it seems to be just way rarer in this version as I never had it before. Just wanted to add for reference, I'm aware that the commit is merged and will be included in next release most likely (although not for 1.21.10 i guess).

Stacktrace for reference:

[13:48:19] [spark-worker-pool-1-thread-1/ERROR]: Exception occurred whilst executing a spark command
java.lang.NullPointerException: Cannot invoke "java.lang.Thread.getId()" because "thread" is null
	at knot/me.lucko.spark.common.sampler.ThreadDumper$Specific.<init>(ThreadDumper.java:145) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.sampler.ThreadDumper$GameThread.setThread(ThreadDumper.java:132) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.sampler.ThreadDumper$GameThread.get(ThreadDumper.java:124) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.minecraft.plugin.MinecraftClientSparkPlugin.getDefaultThreadDumper(MinecraftClientSparkPlugin.java:77) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.command.modules.SamplerModule.profilerStart(SamplerModule.java:199) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.command.modules.SamplerModule.profiler(SamplerModule.java:146) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.SparkPlatform.executeCommand0(SparkPlatform.java:472) ~[spark-1.10.155-fabric.jar:?]
	at knot/me.lucko.spark.common.SparkPlatform.lambda$executeCommand$3(SparkPlatform.java:370) [spark-1.10.155-fabric.jar:?]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545) [?:?]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:328) [?:?]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:309) [?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090) [?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614) [?:?]
	at java.base/java.lang.Thread.run(Thread.java:1474) [?:?]

On an unrelated note, Thread#getId is deprecated since Java 19. Completely irrelevant to this error and using non-deprecated threadId instead would not change anything most probably - but I assume it's deprecated for a good reason by the JDK devs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot initialize /sparkclient profiler || /sparkc profiler — Minecraft 1.21.11

3 participants