Fix Android crash from reusing a completed Result in the inbox listener - #11
Open
fa0311 wants to merge 1 commit into
Open
Fix Android crash from reusing a completed Result in the inbox listener#11fa0311 wants to merge 1 commit into
fa0311 wants to merge 1 commit into
Conversation
…t channel calls to main thread
The inbox response listener captured the MethodChannel.Result from the
original registerInboxResponseListener call and invoked result.error()
on every later inbox response. Since that Result was already completed
at registration time, any subsequent call threw
IllegalStateException("Reply already submitted") and crashed the app.
The registration Result is now completed exactly once, and listener
errors are logged instead.
The listener also called channel.invokeMethod() directly from the
MarketingCloud SDK's callback thread. MethodChannel methods are
@UiThread-only and throw a RuntimeException on debug builds when called
from a background thread. Channel invocations are now posted to the
main thread via a Handler backed by the main looper.
Finally, the listener was never unregistered when the plugin detached
from the engine, leaking it, and repeated registration calls could
stack listeners. onDetachedFromEngine now unregisters the active
listener, and registration is a no-op when a listener is already
active, so at most one listener is ever registered.
nakasyou
approved these changes
Jul 19, 2026
nakasyou
approved these changes
Jul 19, 2026
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.
The Android inbox response listener keeps the
MethodChannel.Resultfrom the original registration call and invokesresult.error(...)on later inbox responses. AResultcan only be completed once, so this crashes withIllegalStateException: Reply already submitted. The listener also callschannel.invokeMethoddirectly from the SDK callback thread (channel methods are@UiThread), and nothing unregisters it on engine detach.Now the registration result is completed exactly once and later errors are just logged, channel calls are posted to the main looper, double registration is guarded, and
onDetachedFromEngineunregisters the listener.