Fix StackOverflowError in Display.setCurrent off-EDT (#4811)#4812
Merged
Conversation
When setCurrent was invoked from a non-EDT thread while Codename One was not running, callSerially's synchronous fallback re-entered setCurrent on the same thread and recursed until the stack overflowed. Move the EDT dispatch ahead of the UI work and fail fast with a clear IllegalStateException when the EDT cannot accept the call. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
|
Compared 37 screenshots: 37 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
|
Compared 37 screenshots: 37 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
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
Display.setCurrentinvoked from a non-EDT thread recursed infinitely intocallSerially->RunnableWrapper.run->setCurrentuntil the JVM stack overflowed (the SOH happened to surface ingetDefaultVirtualKeyboard/setShowVirtualKeyboardbecause those frames sit on top of the loop).codenameOneRunningisfalse(e.g. before init has fully completed or afterdeinitialize),callSeriallyfalls back to executing the runnable synchronously on the calling thread, which re-enterssetCurrentin the same off-EDT state.!isEdt()dispatch ahead of any UI work insetCurrent(so VKB folding, revalidate/repaint, and editing-text branches always execute on the EDT) and fail fast with a clearIllegalStateExceptionwhen the EDT cannot accept the call.Test plan
mvn -pl core compile -Plocal-dev-javasesucceeds (verified locally).ant test-javase/mvn test -Plocal-dev-javase).Display.getInstance().setCurrent(form, false)from a background thread beforeinit(or afterdeinitialize) now throwsIllegalStateExceptionwith a clear message instead of crashing withStackOverflowError.setCurrentcalls (during a running app) continue to dispatch throughcallSeriallyand show the form.🤖 Generated with Claude Code