No-op VMRuntime.setThreadNiceness via ASM transform#2309
Open
colinmarsch wants to merge 2 commits intomasterfrom
Open
No-op VMRuntime.setThreadNiceness via ASM transform#2309colinmarsch wants to merge 2 commits intomasterfrom
colinmarsch wants to merge 2 commits intomasterfrom
Conversation
Layoutlib's VMRuntime.setThreadNiceness calls Thread.setPosixNicenessInternal, a Dalvik-specific method that doesn't exist on the JVM, causing NoSuchMethodError at runtime. Thread niceness is irrelevant for screenshot testing, so replace the method body with a no-op return. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
saket
approved these changes
Mar 17, 2026
Collaborator
saket
left a comment
There was a problem hiding this comment.
Do we already have an existing test for verifying this?
Exercises the real layoutlib VMRuntime through AGP's instrumentation pipeline, confirming the no-op transform prevents NoSuchMethodError on Thread.setPosixNicenessInternal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Added an integration test in 46671bc — it exercises the real layoutlib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoSuchMethodError: java.lang.Thread.setPosixNicenessInternal(int)introduced by the layoutlib bumpVMRuntime.setThreadNicenesscallsThread.setPosixNicenessInternal— a Dalvik-specific native method that doesn't exist on the JVM, crashing at runtime viaHandlerThread.run→Process.setThreadPriority→VMRuntime.setThreadNicenessThreadNicenessVisitorFactory) that replaces thesetThreadNicenessmethod body with a no-op return, since thread niceness is irrelevant for screenshot testingWhy
The recent layoutlib update added a code path that assumes Dalvik-specific JVM internals are available. Rather than patching at a higher level (e.g., no-oping
Process.setThreadPriority), this targets the exact method that calls the missing native, preserving normal behavior elsewhere.