[mojo] Change error behaviour for incoming message processing [chromium/src : main]

0 views
Skip to first unread message

Fred Shih (Gerrit)

unread,
Jan 6, 2026, 2:16:30 PMJan 6
to Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
Attention needed from Alex Gough

Fred Shih added 1 comment

Patchset-level comments
File-level comment, Patchset 17 (Latest):
Fred Shih . resolved

oops, sorry, just realized I accidentally made a bunch of submodule changes when I rebased..

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Gough
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
Gerrit-Change-Number: 7313011
Gerrit-PatchSet: 17
Gerrit-Owner: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Peter Beverloo <pe...@chromium.org>
Gerrit-Attention: Alex Gough <aj...@chromium.org>
Gerrit-Comment-Date: Tue, 06 Jan 2026 19:16:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Gough (Gerrit)

unread,
Jan 7, 2026, 2:26:47 PM (13 days ago) Jan 7
to Fred Shih, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
Attention needed from Fred Shih

Alex Gough added 6 comments

Patchset-level comments
Alex Gough . unresolved

this seems sensible but also feels quite risky as we can't run an experiment - what changes to crashes might we expect and do you have some queries ready to look at crashes in android and webview after this goes in?

File mojo/golden/generated/java/org/chromium/golden/BasicStruct.java.golden
Line 54, Patchset 4: if (decoder0 == null) {
return null;
}
Fred Shih . unresolved

No idea why we even allow this. Is there a use case where we'd want decode to return null because a null decoder was passed in?

Alex Gough

no idea!

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/BadMessageException.java
Line 10, Patchset 17 (Latest): * Indicates an error that occurred at the mojo transport layer. These errors are not caused by the
* user. Instead, this exception indicates some sort of channel corruption or a code defect. When
* this exception is thrown, we can no longer make any assumptions about the validity of the
* underlying channel.
Alex Gough . unresolved

this is sort of confusing - these represent messages that fail validation which can be a user error but in a different process?

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
Line 206, Patchset 17 (Latest): // TODO(crbug.com/469861566): The exception handler should close the pipe in this
// case. The current impl does not really handle this, so we'll just maintain the
// current behaviour to limit the blast radius of this CL.
Alex Gough . unresolved

reword to not talk about 'this CL' this will be in the code

can we dumpwithoutcrashing here?

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
Line 302, Patchset 17 (Latest): // Rewrap the BadMessageException to conform with existing
// behaviour.
Alex Gough . unresolved

comment is confusing reword to explain why it happens /now/ or TODO what would be an improvement (or just the comment above is enough)

Line 321, Patchset 17 (Latest): // Rewrap the BadMessageException to conform with existing
// behaviour.
Alex Gough . unresolved

ditto

Open in Gerrit

Related details

Attention is currently required from:
  • Fred Shih
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
Gerrit-Change-Number: 7313011
Gerrit-PatchSet: 17
Gerrit-Owner: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Peter Beverloo <pe...@chromium.org>
Gerrit-Attention: Fred Shih <ff...@chromium.org>
Gerrit-Comment-Date: Wed, 07 Jan 2026 19:26:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Fred Shih <ff...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fred Shih (Gerrit)

unread,
Jan 7, 2026, 3:50:14 PM (13 days ago) Jan 7
to Sky Malice, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
Attention needed from Alex Gough and Sky Malice

Fred Shih added 6 comments

Patchset-level comments
Alex Gough . unresolved

this seems sensible but also feels quite risky as we can't run an experiment - what changes to crashes might we expect and do you have some queries ready to look at crashes in android and webview after this goes in?

Fred Shih

tbh -- I can't really of any way to get more metrics for this change besides keeping a close eye at the webview and android crash reports. Unfortunately there just isn't any infra regarding error rates for the java binding. We should probably change that.

That being said, we did get sorta lucky that old implementation catches RuntimeException (which is a big nono). This CL adds a checked exception, so if anything, we should be reducing the amount of places we will be encountering unexpected exceptions...

I added Sky to take a look at this CL -- maybe he'll have some ideas.

File mojo/golden/generated/java/org/chromium/golden/BasicStruct.java.golden
Line 54, Patchset 4: if (decoder0 == null) {
return null;
}
Fred Shih . resolved

No idea why we even allow this. Is there a use case where we'd want decode to return null because a null decoder was passed in?

Alex Gough

no idea!

Fred Shih

welp, I'll open this can of worms later on down the road!

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/BadMessageException.java
Line 10, Patchset 17: * Indicates an error that occurred at the mojo transport layer. These errors are not caused by the

* user. Instead, this exception indicates some sort of channel corruption or a code defect. When
* this exception is thrown, we can no longer make any assumptions about the validity of the
* underlying channel.
Alex Gough . resolved

this is sort of confusing - these represent messages that fail validation which can be a user error but in a different process?

Fred Shih

you're right. When I came up with this exception, I was originally thinking of bad messages coming from the mojo runtime. But a client could also create a bad message. Updated the comment.

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
Line 206, Patchset 17: // TODO(crbug.com/469861566): The exception handler should close the pipe in this

// case. The current impl does not really handle this, so we'll just maintain the
// current behaviour to limit the blast radius of this CL.
Alex Gough . resolved

reword to not talk about 'this CL' this will be in the code

can we dumpwithoutcrashing here?

Fred Shih

done -- I did try this, but this turned out to be way more difficult than I thought.

sky pointed me at:
https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/crash/ChromePureJavaExceptionReporter.java;l=84;drc=af9dfc75465d20b475bbd00b025ce2211f9f6e45;bpv=1;bpt=1?q=ChromePureJavaExceptionReporter.java

But unfortunately all the crash components depend on mojo at some point, so we will probably have to roll our own crash reporter (or refactor their build if possible..).

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
Line 302, Patchset 17: // Rewrap the BadMessageException to conform with existing
// behaviour.
Alex Gough . resolved

comment is confusing reword to explain why it happens /now/ or TODO what would be an improvement (or just the comment above is enough)

Fred Shih

Done

Line 321, Patchset 17: // Rewrap the BadMessageException to conform with existing
// behaviour.
Alex Gough . resolved

ditto

Fred Shih

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Gough
  • Sky Malice
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
Gerrit-Change-Number: 7313011
Gerrit-PatchSet: 17
Gerrit-Owner: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Peter Beverloo <pe...@chromium.org>
Gerrit-Attention: Sky Malice <sk...@chromium.org>
Gerrit-Attention: Alex Gough <aj...@chromium.org>
Gerrit-Comment-Date: Wed, 07 Jan 2026 20:50:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Alex Gough <aj...@chromium.org>
Comment-In-Reply-To: Fred Shih <ff...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Fred Shih (Gerrit)

unread,
Jan 7, 2026, 3:53:44 PM (13 days ago) Jan 7
to Sky Malice, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
Attention needed from Alex Gough and Sky Malice

Fred Shih added 1 comment

Patchset-level comments
Alex Gough . unresolved

this seems sensible but also feels quite risky as we can't run an experiment - what changes to crashes might we expect and do you have some queries ready to look at crashes in android and webview after this goes in?

Fred Shih

tbh -- I can't really of any way to get more metrics for this change besides keeping a close eye at the webview and android crash reports. Unfortunately there just isn't any infra regarding error rates for the java binding. We should probably change that.

That being said, we did get sorta lucky that old implementation catches RuntimeException (which is a big nono). This CL adds a checked exception, so if anything, we should be reducing the amount of places we will be encountering unexpected exceptions...

I added Sky to take a look at this CL -- maybe he'll have some ideas.

Fred Shih

oh and to be more clear, I don't expect any additional crashes that weren't already present. If anything, I'd expect a reduction in crashes because this CL caught some client code which could've triggered some unhandled exceptions.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Gough
  • Sky Malice
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
Gerrit-Change-Number: 7313011
Gerrit-PatchSet: 18
Gerrit-Owner: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Peter Beverloo <pe...@chromium.org>
Gerrit-Attention: Sky Malice <sk...@chromium.org>
Gerrit-Attention: Alex Gough <aj...@chromium.org>
Gerrit-Comment-Date: Wed, 07 Jan 2026 20:53:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Fred Shih <ff...@chromium.org>
Comment-In-Reply-To: Alex Gough <aj...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Sky Malice (Gerrit)

unread,
Jan 12, 2026, 12:18:52 AM (9 days ago) Jan 12
to Fred Shih, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
Attention needed from Alex Gough and Fred Shih

Sky Malice voted and added 7 comments

Votes added by Sky Malice

Code-Review+1

7 comments

Patchset-level comments
File-level comment, Patchset 18 (Latest):
Sky Malice . unresolved

I don't use mojo bindings so I may be missing some context of what's going on here. Closing the pipe and matching C++ behavior sounds great. I'm a bit surprised by the switch from the runtime exception to the checked exception, it feels somewhat hostile to clients. So often clients don't really care and assume the happy case. For the fraction that want to handle errors, they could still catch specific exceptions that extend RuntimeException, right?

Additionally, if you didn't change the checked-ness of the exception, this CL would be much smaller. And there may actually be some small pieces in RouterImpl#dispatchMessages or something that you could consider feature gating two versions of the behavior. I'm not exactly sure.

I don't know enough to be concerned here, this all seems mostly reasonable to me though.

File components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestSpec.java
Line 78, Patchset 18 (Latest): } catch (BadMessageException e) {
throw new IllegalStateException(e);
Sky Malice . unresolved

So many call sites are catching the checked exception and just wrapping with an unchecked exception. Does it really make sense for deserialize to have to throw a checked exception?

File components/webauthn/android/java/src/org/chromium/components/webauthn/cred_man/CredManHelper.java
Line 619, Patchset 18 (Parent): } catch (org.chromium.mojo.bindings.DeserializationException e) {
Sky Malice . unresolved

This is odd that we're fully qualifying the exception here, I guess it doesn't really matter.

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
Line 205, Patchset 18 (Latest): } catch (BadMessageException e) {
Sky Malice . unresolved

I would have excepted this to come before RuntimeException, the BME feels much more narrowly scoped. And if you ever make it extend RuntimeException, we'd probably want its specific handling to be run.

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
Line 293, Patchset 18 (Latest): // TODO(crbug.com/469861566?): this is not correct, because it swallows any
Sky Malice . unresolved

What does this `?` here mean?

Line 303, Patchset 18 (Latest): // Needed to match existing behaviour before |BadMessageException|
// was introduced.
Sky Malice . unresolved

I don't understand this. Why do you need to match the old behavior? The whole client is being updated in this CL. What do I not understand?

File mojo/public/java/bindings/src/org/chromium/mojo/bindings/RouterImpl.java
Line 247, Patchset 18 (Latest): private static enum DispatchResult {
Sky Malice . unresolved

Does this strictly need to be an enum? Typically we use @IntDef for the smaller overhead.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Gough
  • Fred Shih
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
    Gerrit-Change-Number: 7313011
    Gerrit-PatchSet: 18
    Gerrit-Owner: Fred Shih <ff...@chromium.org>
    Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
    Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
    Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Peter Beverloo <pe...@chromium.org>
    Gerrit-Attention: Fred Shih <ff...@chromium.org>
    Gerrit-Attention: Alex Gough <aj...@chromium.org>
    Gerrit-Comment-Date: Mon, 12 Jan 2026 05:18:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fred Shih (Gerrit)

    unread,
    Jan 12, 2026, 8:45:37 PM (8 days ago) Jan 12
    to Sky Malice, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
    Attention needed from Alex Gough and Sky Malice

    Fred Shih added 8 comments

    Patchset-level comments
    Sky Malice . unresolved

    I don't use mojo bindings so I may be missing some context of what's going on here. Closing the pipe and matching C++ behavior sounds great. I'm a bit surprised by the switch from the runtime exception to the checked exception, it feels somewhat hostile to clients. So often clients don't really care and assume the happy case. For the fraction that want to handle errors, they could still catch specific exceptions that extend RuntimeException, right?

    Additionally, if you didn't change the checked-ness of the exception, this CL would be much smaller. And there may actually be some small pieces in RouterImpl#dispatchMessages or something that you could consider feature gating two versions of the behavior. I'm not exactly sure.

    I don't know enough to be concerned here, this all seems mostly reasonable to me though.

    Fred Shih

    Thanks for taking a look! It's always nice to have someone without any context to go over the code for some objective feedback :)

    Regarding the checked exception: it's not really exposed to clients. Most of the checked exception *should* stay within the mojo runtime. Unfortunately the current implementation doesn't really do a great job separating mojo internal code and client facing external code. This is where we end up with unexpected client library behaviours (e.g.: the only function that checks if an enum value is valid will throw exceptions instead of returning boolean).

    Having checked exception in the mojo runtime also ensures that we're able to propagate pipe closing errors more effectively (and ensured that they're handled). Without the checked exception, most of the runtime code just uses a boolean return to signal that something has gone wrong. At some places it turns into a RuntimeException when a method actually needs to return something. In order to get around this, the current implementation has a catch-them-all handler in the Connector. The really nasty side effect of this is that this will *also* swallow any exception thrown by the client implementation.

    File-level comment, Patchset 19 (Latest):
    Fred Shih . resolved

    thanks for the feedback!

    File components/payments/content/android/java/src/org/chromium/components/payments/PaymentRequestSpec.java
    Line 78, Patchset 18: } catch (BadMessageException e) {
    throw new IllegalStateException(e);
    Sky Malice . resolved

    So many call sites are catching the checked exception and just wrapping with an unchecked exception. Does it really make sense for deserialize to have to throw a checked exception?

    Fred Shih

    I mulled about this for a while (I mulled about this before I made the initial change too, lol). In the end I was inclined to agree with you. It would have been nice if we had an internal and public deserialization signatures, but at this point I think Deserialization is widely used enough that it probably doesn't make sense to change it.

    I changed DeserializationException back to a RuntimeException and added an UnmarshalException that is intended to be used by the mojo runtime internally. It's not ideal, but probably the most reasonable approach at this point.

    That allowed me to revert a bunch of changes. I still think it's funky to call validateEnum to check whether an enum value is valid, but that can be cleaned up in a separate CL..

    File components/webauthn/android/java/src/org/chromium/components/webauthn/cred_man/CredManHelper.java
    Line 619, Patchset 18 (Parent): } catch (org.chromium.mojo.bindings.DeserializationException e) {
    Sky Malice . resolved

    This is odd that we're fully qualifying the exception here, I guess it doesn't really matter.

    Fred Shih

    ended up reverting this file

    File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Connector.java
    Line 205, Patchset 18: } catch (BadMessageException e) {
    Sky Malice . resolved

    I would have excepted this to come before RuntimeException, the BME feels much more narrowly scoped. And if you ever make it extend RuntimeException, we'd probably want its specific handling to be run.

    Fred Shih

    Done

    File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
    Line 293, Patchset 18: // TODO(crbug.com/469861566?): this is not correct, because it swallows any
    Sky Malice . resolved

    What does this `?` here mean?

    Fred Shih

    most likely a copy paste error

    Line 303, Patchset 18: // Needed to match existing behaviour before |BadMessageException|
    // was introduced.
    Sky Malice . unresolved

    I don't understand this. Why do you need to match the old behavior? The whole client is being updated in this CL. What do I not understand?

    Fred Shih

    The correct behaviour in this case is to close the pipe then rethrow the exception, because all BadMessages should cause a pipe closure.

    Blindly letting the exception propagate would lead to UB if an upper layer happens to catch the exception.

    I'll make the change in a later CL, I'm attempting to limit the scope of this change (which is already way too yuge at this point...). Does that make sense?

    File mojo/public/java/bindings/src/org/chromium/mojo/bindings/RouterImpl.java
    Line 247, Patchset 18: private static enum DispatchResult {
    Sky Malice . resolved

    Does this strictly need to be an enum? Typically we use @IntDef for the smaller overhead.

    Fred Shih

    nope, didn't know. Updated!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Gough
    • Sky Malice
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
      Gerrit-Change-Number: 7313011
      Gerrit-PatchSet: 19
      Gerrit-Owner: Fred Shih <ff...@chromium.org>
      Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
      Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
      Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Peter Beverloo <pe...@chromium.org>
      Gerrit-Attention: Sky Malice <sk...@chromium.org>
      Gerrit-Attention: Alex Gough <aj...@chromium.org>
      Gerrit-Comment-Date: Tue, 13 Jan 2026 01:45:27 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Sky Malice <sk...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Fred Shih (Gerrit)

      unread,
      Jan 16, 2026, 4:48:43 PM (4 days ago) Jan 16
      to Sky Malice, Code Review Nudger, Peter Beverloo, AyeAye, Alex Gough, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
      Attention needed from Alex Gough and Sky Malice

      Fred Shih added 1 comment

      Patchset-level comments
      Alex Gough . unresolved

      this seems sensible but also feels quite risky as we can't run an experiment - what changes to crashes might we expect and do you have some queries ready to look at crashes in android and webview after this goes in?

      Fred Shih

      tbh -- I can't really of any way to get more metrics for this change besides keeping a close eye at the webview and android crash reports. Unfortunately there just isn't any infra regarding error rates for the java binding. We should probably change that.

      That being said, we did get sorta lucky that old implementation catches RuntimeException (which is a big nono). This CL adds a checked exception, so if anything, we should be reducing the amount of places we will be encountering unexpected exceptions...

      I added Sky to take a look at this CL -- maybe he'll have some ideas.

      Fred Shih

      oh and to be more clear, I don't expect any additional crashes that weren't already present. If anything, I'd expect a reduction in crashes because this CL caught some client code which could've triggered some unhandled exceptions.

      Fred Shih

      Ok, new day and I am slightly less dumb than I was yesterday. I have a crash report query that will show all mojo bindings exceptions, here:

      https://crash.corp.google.com/browse?q=%28product_name%3D%27AndroidWebView%27+OR+product_name%3D%27Chrome_Android%27%29+AND+STARTS_WITH%28expanded_custom_data.ChromeCrashProto.magic_signature_1.name%2C+%27%5BAndroid+Java+Exception%5D+org.chromium.mojo%27%29#-property-selector,-samplereports,+productversion:200,-processtype:100,-clientid,+operatingsystem,+url,+simplifiedurl,+extensions,+day:60

      Turns out we actually have a few exceptions that have been lurking. Interestingly, they are serialization exceptions. I manually induced a crash, a report can be seen here:

      http://go/crash/cd51739d4acd9748

      To send reports, we can use JavExceptionReporter:
      https://source.chromium.org/chromium/chromium/src/+/main:base/android/java/src/org/chromium/base/JavaExceptionReporter.java?q=javaexceptionreporter

      This is installed by the JNI and will capture all unhandled exceptions in Java and upload it to crashpad. This works for both Android Chrome and Android Webview.

      The numbers is quite low (0, so as low as it can get), so any regressino should be easy to spot.

      Does that sound reasonable to you?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alex Gough
      • Sky Malice
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
      Gerrit-Change-Number: 7313011
      Gerrit-PatchSet: 22
      Gerrit-Owner: Fred Shih <ff...@chromium.org>
      Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
      Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
      Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Peter Beverloo <pe...@chromium.org>
      Gerrit-Attention: Sky Malice <sk...@chromium.org>
      Gerrit-Attention: Alex Gough <aj...@chromium.org>
      Gerrit-Comment-Date: Fri, 16 Jan 2026 21:48:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Alex Gough (Gerrit)

      unread,
      Jan 16, 2026, 4:51:33 PM (4 days ago) Jan 16
      to Fred Shih, Alex Gough, Sky Malice, Code Review Nudger, Peter Beverloo, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
      Attention needed from Fred Shih and Sky Malice

      Alex Gough voted and added 2 comments

      Votes added by Alex Gough

      Code-Review+1

      2 comments

      Patchset-level comments

      this seems sensible but also feels quite risky as we can't run an experiment - what changes to crashes might we expect and do you have some queries ready to look at crashes in android and webview after this goes in?

      Fred Shih

      tbh -- I can't really of any way to get more metrics for this change besides keeping a close eye at the webview and android crash reports. Unfortunately there just isn't any infra regarding error rates for the java binding. We should probably change that.

      That being said, we did get sorta lucky that old implementation catches RuntimeException (which is a big nono). This CL adds a checked exception, so if anything, we should be reducing the amount of places we will be encountering unexpected exceptions...

      I added Sky to take a look at this CL -- maybe he'll have some ideas.

      Fred Shih

      oh and to be more clear, I don't expect any additional crashes that weren't already present. If anything, I'd expect a reduction in crashes because this CL caught some client code which could've triggered some unhandled exceptions.

      Fred Shih

      Ok, new day and I am slightly less dumb than I was yesterday. I have a crash report query that will show all mojo bindings exceptions, here:

      https://crash.corp.google.com/browse?q=%28product_name%3D%27AndroidWebView%27+OR+product_name%3D%27Chrome_Android%27%29+AND+STARTS_WITH%28expanded_custom_data.ChromeCrashProto.magic_signature_1.name%2C+%27%5BAndroid+Java+Exception%5D+org.chromium.mojo%27%29#-property-selector,-samplereports,+productversion:200,-processtype:100,-clientid,+operatingsystem,+url,+simplifiedurl,+extensions,+day:60

      Turns out we actually have a few exceptions that have been lurking. Interestingly, they are serialization exceptions. I manually induced a crash, a report can be seen here:

      http://go/crash/cd51739d4acd9748

      To send reports, we can use JavExceptionReporter:
      https://source.chromium.org/chromium/chromium/src/+/main:base/android/java/src/org/chromium/base/JavaExceptionReporter.java?q=javaexceptionreporter

      This is installed by the JNI and will capture all unhandled exceptions in Java and upload it to crashpad. This works for both Android Chrome and Android Webview.

      The numbers is quite low (0, so as low as it can get), so any regressino should be easy to spot.

      Does that sound reasonable to you?

      Alex Gough

      Yep thanks for digging into this - I'm happy once remaining comments are resolved.

      File-level comment, Patchset 23 (Latest):
      Alex Gough . resolved

      lgtm mojo

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Fred Shih
      • Sky Malice
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
        Gerrit-Change-Number: 7313011
        Gerrit-PatchSet: 23
        Gerrit-Owner: Fred Shih <ff...@chromium.org>
        Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
        Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
        Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Peter Beverloo <pe...@chromium.org>
        Gerrit-Attention: Sky Malice <sk...@chromium.org>
        Gerrit-Attention: Fred Shih <ff...@chromium.org>
        Gerrit-Comment-Date: Fri, 16 Jan 2026 21:51:23 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sky Malice (Gerrit)

        unread,
        Jan 16, 2026, 5:26:46 PM (4 days ago) Jan 16
        to Fred Shih, Alex Gough, Code Review Nudger, Peter Beverloo, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org
        Attention needed from Fred Shih

        Sky Malice voted and added 2 comments

        Votes added by Sky Malice

        Code-Review+1

        2 comments

        Patchset-level comments
        File-level comment, Patchset 18:
        Sky Malice . resolved

        I don't use mojo bindings so I may be missing some context of what's going on here. Closing the pipe and matching C++ behavior sounds great. I'm a bit surprised by the switch from the runtime exception to the checked exception, it feels somewhat hostile to clients. So often clients don't really care and assume the happy case. For the fraction that want to handle errors, they could still catch specific exceptions that extend RuntimeException, right?

        Additionally, if you didn't change the checked-ness of the exception, this CL would be much smaller. And there may actually be some small pieces in RouterImpl#dispatchMessages or something that you could consider feature gating two versions of the behavior. I'm not exactly sure.

        I don't know enough to be concerned here, this all seems mostly reasonable to me though.

        Fred Shih

        Thanks for taking a look! It's always nice to have someone without any context to go over the code for some objective feedback :)

        Regarding the checked exception: it's not really exposed to clients. Most of the checked exception *should* stay within the mojo runtime. Unfortunately the current implementation doesn't really do a great job separating mojo internal code and client facing external code. This is where we end up with unexpected client library behaviours (e.g.: the only function that checks if an enum value is valid will throw exceptions instead of returning boolean).

        Having checked exception in the mojo runtime also ensures that we're able to propagate pipe closing errors more effectively (and ensured that they're handled). Without the checked exception, most of the runtime code just uses a boolean return to signal that something has gone wrong. At some places it turns into a RuntimeException when a method actually needs to return something. In order to get around this, the current implementation has a catch-them-all handler in the Connector. The really nasty side effect of this is that this will *also* swallow any exception thrown by the client implementation.

        Sky Malice

        also swallow any exception thrown by the client implementation.

        Oh that is tricky, I see. That makes a lot of sense, thanks! Your changes sound good to me.

        File mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
        Line 303, Patchset 18: // Needed to match existing behaviour before |BadMessageException|
        // was introduced.
        Sky Malice . resolved

        I don't understand this. Why do you need to match the old behavior? The whole client is being updated in this CL. What do I not understand?

        Fred Shih

        The correct behaviour in this case is to close the pipe then rethrow the exception, because all BadMessages should cause a pipe closure.

        Blindly letting the exception propagate would lead to UB if an upper layer happens to catch the exception.

        I'll make the change in a later CL, I'm attempting to limit the scope of this change (which is already way too yuge at this point...). Does that make sense?

        Sky Malice

        Thanks for the detailed explanation! Yes, makes more sense now.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Fred Shih
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
          Gerrit-Change-Number: 7313011
          Gerrit-PatchSet: 23
          Gerrit-Owner: Fred Shih <ff...@chromium.org>
          Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
          Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
          Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          Gerrit-CC: Peter Beverloo <pe...@chromium.org>
          Gerrit-Attention: Fred Shih <ff...@chromium.org>
          Gerrit-Comment-Date: Fri, 16 Jan 2026 22:26:35 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Sky Malice <sk...@chromium.org>
          Comment-In-Reply-To: Fred Shih <ff...@chromium.org>
          satisfied_requirement
          open
          diffy

          Fred Shih (Gerrit)

          unread,
          4:57 PM (1 hour ago) 4:57 PM
          to Sky Malice, Alex Gough, Code Review Nudger, Peter Beverloo, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, cblume...@chromium.org, devtools...@chromium.org, penghuan...@chromium.org, chromotin...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, derinel+wat...@google.com, sloboda...@chromium.org, lizeb+watch...@chromium.org, webauthn...@chromium.org

          Fred Shih voted and added 1 comment

          Votes added by Fred Shih

          Commit-Queue+2

          1 comment

          Patchset-level comments
          File-level comment, Patchset 23 (Latest):
          Fred Shih . resolved

          Thank you for the reviews! I learned quite a bit. Sorry this became such a monster..

          Open in Gerrit

          Related details

          Attention set is empty
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I970c421402e9cee60eca668cb8627ce571cce5d0
          Gerrit-Change-Number: 7313011
          Gerrit-PatchSet: 23
          Gerrit-Owner: Fred Shih <ff...@chromium.org>
          Gerrit-Reviewer: Alex Gough <aj...@chromium.org>
          Gerrit-Reviewer: Fred Shih <ff...@chromium.org>
          Gerrit-Reviewer: Sky Malice <sk...@chromium.org>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          Gerrit-CC: Peter Beverloo <pe...@chromium.org>
          Gerrit-Comment-Date: Tue, 20 Jan 2026 21:57:50 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages