-
Notifications
You must be signed in to change notification settings - Fork 6k
[Android] Drops semantics query when app is not attached #52040
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -873,8 +873,9 @@ private native void nativeDispatchSemanticsAction( | |||
@UiThread | |||
public void setSemanticsEnabled(boolean enabled) { | |||
ensureRunningOnMainThread(); | |||
ensureAttachedToNative(); | |||
nativeSetSemanticsEnabled(nativeShellHolderId, enabled); | |||
if (isAttached()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @reidbaker is there a good way to test this?
Things i have tried:
- make nativeSetSemanticsEnabled public and mock it using mockito.
- I try creating a public method that just call
nativeSetSemanticsEnabled
and use spy to mock the instance.
both of them throws UnSatisfiedLink error on nativeSetSemanticsEnabled
. The only way I can think of is to extends the entire FlutterJNI and override method to do nothing, but I am wondering if that is preferred or is there any other way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this pr does not have a test I cant see what testing environment you are using. My guess is that if your test contains whatever dependency has nativeSetSemanticsEnabled then the issue is that your c code needs to run on an android device (or maybe with robolectric).
I also found this chromium documentation https://www.chromium.org/developers/testing/android-tests/testing-android-code-that-crosses-the-c-java-boundary/ that suggest that a spy is the correct solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can't find a good way to use spy
without trigger the error. I end up override entire class a mock out the part i don't need
@chunhtai I am going through my pr requests and found this. I believe you are not waiting on me if that is the case let me know. |
no, I have some other ideas to test this code. I will let you know once this pr is ready |
follow up to see if this is ready for review. |
Follow up again on this pr, can we close it if it is still not ready for review? |
I have time know, will ready this pr within this week |
857c00b
to
c9e5da9
Compare
…sions) (#154137) Manual roll requested by [email protected] flutter/engine@365b0c7...f645ca5 2024-08-26 [email protected] Revert dart to b81b344a194f (flutter/engine#54782) 2024-08-26 [email protected] [web] set the "dialog" ARIA role unconditionally (flutter/engine#54761) 2024-08-26 [email protected] Revert "Test running the macOS engine has no stray logging" (flutter/engine#54778) 2024-08-26 [email protected] clangd_check: write .clangd as part of test (flutter/engine#54766) 2024-08-26 [email protected] Roll Dart SDK from c7eb3230248a to 94c21ec02e28 (2 revisions) (flutter/engine#54776) 2024-08-26 [email protected] [Android] Drops semantics query when app is not attached (flutter/engine#52040) 2024-08-26 [email protected] [ui] fix missing color conversion in drawAtlas. (flutter/engine#54750) 2024-08-26 [email protected] Roll Skia from ce0656c1d79c to a05dbd2a60f0 (3 revisions) (flutter/engine#54774) 2024-08-26 [email protected] Roll Fuchsia Linux SDK from CVnRW3RAZuTq0lVaw... to QqRZlA9wVbeg4WoPz... (flutter/engine#54770) 2024-08-26 [email protected] [Impeller] delete impeller image class. (flutter/engine#54767) 2024-08-25 [email protected] [Impeller] more test migration. (flutter/engine#54763) 2024-08-25 [email protected] [macOS] Add TODOs to remove AppKit bug workaround (flutter/engine#54764) 2024-08-25 [email protected] Roll Fuchsia Linux SDK from 5uR6WvDV5FX-aZgKQ... to CVnRW3RAZuTq0lVaw... (flutter/engine#54765) 2024-08-24 [email protected] Roll Skia from d59df6f6f4f3 to ce0656c1d79c (2 revisions) (flutter/engine#54760) 2024-08-24 [email protected] Roll Skia from 741972846fa2 to d59df6f6f4f3 (1 revision) (flutter/engine#54758) 2024-08-24 [email protected] Roll Fuchsia Linux SDK from 0d2McFgsNwG-5r1Rb... to 5uR6WvDV5FX-aZgKQ... (flutter/engine#54757) 2024-08-24 [email protected] Roll Dart SDK from 586ba94c96a4 to c7eb3230248a (2 revisions) (flutter/engine#54755) 2024-08-24 [email protected] Roll Skia from 0086a17e0d4c to 741972846fa2 (3 revisions) (flutter/engine#54753) 2024-08-24 [email protected] Roll Dart SDK from b81b344a194f to 586ba94c96a4 (1 revision) (flutter/engine#54752) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 0d2McFgsNwG- to QqRZlA9wVbeg If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…sions) (flutter#154137) Manual roll requested by [email protected] flutter/engine@365b0c7...f645ca5 2024-08-26 [email protected] Revert dart to b81b344a194f (flutter/engine#54782) 2024-08-26 [email protected] [web] set the "dialog" ARIA role unconditionally (flutter/engine#54761) 2024-08-26 [email protected] Revert "Test running the macOS engine has no stray logging" (flutter/engine#54778) 2024-08-26 [email protected] clangd_check: write .clangd as part of test (flutter/engine#54766) 2024-08-26 [email protected] Roll Dart SDK from c7eb3230248a to 94c21ec02e28 (2 revisions) (flutter/engine#54776) 2024-08-26 [email protected] [Android] Drops semantics query when app is not attached (flutter/engine#52040) 2024-08-26 [email protected] [ui] fix missing color conversion in drawAtlas. (flutter/engine#54750) 2024-08-26 [email protected] Roll Skia from ce0656c1d79c to a05dbd2a60f0 (3 revisions) (flutter/engine#54774) 2024-08-26 [email protected] Roll Fuchsia Linux SDK from CVnRW3RAZuTq0lVaw... to QqRZlA9wVbeg4WoPz... (flutter/engine#54770) 2024-08-26 [email protected] [Impeller] delete impeller image class. (flutter/engine#54767) 2024-08-25 [email protected] [Impeller] more test migration. (flutter/engine#54763) 2024-08-25 [email protected] [macOS] Add TODOs to remove AppKit bug workaround (flutter/engine#54764) 2024-08-25 [email protected] Roll Fuchsia Linux SDK from 5uR6WvDV5FX-aZgKQ... to CVnRW3RAZuTq0lVaw... (flutter/engine#54765) 2024-08-24 [email protected] Roll Skia from d59df6f6f4f3 to ce0656c1d79c (2 revisions) (flutter/engine#54760) 2024-08-24 [email protected] Roll Skia from 741972846fa2 to d59df6f6f4f3 (1 revision) (flutter/engine#54758) 2024-08-24 [email protected] Roll Fuchsia Linux SDK from 0d2McFgsNwG-5r1Rb... to 5uR6WvDV5FX-aZgKQ... (flutter/engine#54757) 2024-08-24 [email protected] Roll Dart SDK from 586ba94c96a4 to c7eb3230248a (2 revisions) (flutter/engine#54755) 2024-08-24 [email protected] Roll Skia from 0086a17e0d4c to 741972846fa2 (3 revisions) (flutter/engine#54753) 2024-08-24 [email protected] Roll Dart SDK from b81b344a194f to 586ba94c96a4 (1 revision) (flutter/engine#54752) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 0d2McFgsNwG- to QqRZlA9wVbeg If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Is seems automatic test may send a11y query before the engine is attached. Add a guard to guard against it.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.