Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel Binary APK frozen on Splash Screen #3810

Closed
anandwana001 opened this issue Sep 16, 2021 · 8 comments · Fixed by #3795 or #3866
Closed

Bazel Binary APK frozen on Splash Screen #3810

anandwana001 opened this issue Sep 16, 2021 · 8 comments · Fixed by #3795 or #3866
Assignees
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@anandwana001
Copy link
Contributor

Describe the bug
Launching the testing APK gets frozen on SplashActivity.

To Reproduce
Internal Testing

Expected behavior
Work smoothly on all devices.

Screenshots
If applicable, add screenshots or videos to help explain your problem.

Device

  • Device/emulator being used - Pixel XL 3a (not working)/ Redmi (Working)
  • SDK version - API 28 and Android 11

Additional context

2021-09-16 23:30:37.740 I/ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.oppia.android/.app.splash.SplashActivity bnds=[439,80][641,379]} from uid 10064
2021-09-16 23:30:37.747 E/statsd: Predicate 5980654721335871649 dropping data for dimension key (10)0x2010101->10437[I] (10)0x30000->*launch*[S] 
2021-09-16 23:30:37.767 I/ActivityManager: Start proc 3893:org.oppia.android/u0a437 for pre-top-activity {org.oppia.android/org.oppia.android.app.splash.SplashActivity}
2021-09-16 23:30:37.778 E/g.oppia.androi: Not starting debugger since process cannot load the jdwp agent.
2021-09-16 23:30:37.813 W/g.oppia.androi: JIT profile information will not be recorded: profile file does not exist.
2021-09-16 23:30:37.826 I/MultiDex: VM with version 2.1.0 has multidex support
2021-09-16 23:30:37.826 I/MultiDex: Installing application
2021-09-16 23:30:37.826 I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2021-09-16 23:30:37.841 W/DynamiteModule: Local module descriptor class for com.google.android.gms.measurement.dynamite not found.
2021-09-16 23:30:37.841 W/DynamiteModule: Failed to load module via V2: java.lang.NoSuchFieldException: No field sClassLoader in class Lbg/b; (declaration of 'bg.b' appears in /data/app/~~1o1OMvmxLfLRH6EbQQ7Ovg==/org.oppia.android-eHdGVSc-FveRZnY884YTBg==/base.apk)
2021-09-16 23:30:37.853 I/FirebaseCrashlytics: Initializing Crashlytics 17.1.1
2021-09-16 23:30:37.857 I/g.oppia.androi: The ClassLoaderContext is a special shared library.
2021-09-16 23:30:37.864 I/g.oppia.androi: The ClassLoaderContext is a special shared library.
2021-09-16 23:30:37.870 I/FirebaseInitProvider: FirebaseApp initialization successful
2021-09-16 23:30:37.887 I/TetheringManager: registerTetheringEventCallback:org.oppia.android
2021-09-16 23:30:37.902 I/DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:0 and remote module com.google.android.gms.measurement.dynamite:51
2021-09-16 23:30:37.902 I/DynamiteModule: Selected remote version of com.google.android.gms.measurement.dynamite, version >= 51

@anandwana001 anandwana001 added this to the Alpha MR3 milestone Sep 16, 2021
@anandwana001 anandwana001 changed the title Bazel Binary APK froze on Splash Screen Bazel Binary APK frozen on Splash Screen Sep 16, 2021
@anandwana001
Copy link
Contributor Author

Removing the livedata observer on SplashActivityPrsenter fix the issue.

BenHenning added a commit that referenced this issue Sep 28, 2021
…g language selection support (#3795)

* Add support for AABs, build flavors, and proguard.

There are a lot of details to cover here--see the PR for the complete
context.

* Lint & codeowner fixes.

* Fix failures.

- Add missing codeowner
- Add support for configuring base branch reference
- Update CI for dev/alpha AAB builds to use 'develop' since there's no
  origin configured by default in the workflows

* Different attempt to fix bad develop reference in CI.

* Initial commit.

This is needed to open a PR on GitHub. This commit is being made so that
the PR can start off in a broken Actions state.

This also initially disables most non-Bazel workflows to make workflow
iteration faster and less impacting on other team members.

* Introduce infrastructure for batching.

This introduces a new mechanism for passing lists of tests to sharded
test targets in CI, and hooks it up. No actual sharding is occurring
yet. This led to some simplifications in the CI workflow since the
script can be more dynamic in computing the full list of targets (which
also works around a previous bug with instrumentation tests being run).
Java proto lite also needed to be upgraded for the scripts to be able to
use it.

More testing/documentation needed as this functionality continues to
expand.

* Add bucketing strategy.

This simply partitions bucketed groups of targets into chunks of 10 for
each run. Only 3 buckets are currently retained to test sharding in CI
before introducing full support.

* Fix caching & stabilize builds.

Fixes some caching bucket and output bugs. Also, introduces while loop &
keep_going to introduce resilience against app test build failures (or
just test failures in general).

* Increase sharding & add randomization.

Also, enable other workflows.

Note that CI shouldn't fully pass yet since some documentation and
testing needs to be added yet, but this is meant to be a more realistic
test of the CI environment before the PR is finished.

* Improving partitionin & readability.

Adds a human-readable prefix to make the shards look a bit nicer.

Also, adds more fine-tuned partitioning to bucket & reduce shard counts
to improve overall timing. Will need to be tested in CI.

* Add new tests & fix static analysis errors.

* Fix script.

A newly computed variable wasn't updated to be used in an earlier
change.

* Fix broken tests & test configuration.

Add docstrings for proto.

* Fix mistake from earlier commit.

* Try 10 max parallel actions instead.

See
#3757 (comment)
for context.

* Fix another error from an earlier commit.

* Localisation updates from https://translatewiki.net.

* Fix mv command so it works on Linux & OSX.

Neither 'mv -t' nor piping to mv work on OSX so we needed to find an
alternative (in this case just trying to move everything). This actually
works a bit better since it's doing a per-file move rather than
accommodating for files that shouldn't be moved (which isn't an issue
since the destination directory is different than the one containing the
AAB file).

* Introduce initial domain layer for translations.

Documentation, thorough tests, and detailed description of these changes
are still needed.

* Initial app layer implementation for translations.

This demonstrates working string selection for system-based and
overwritten app languages, including necessary activity recreation &
layout direction overwriting.

This also includes a bunch of Dagger infra refactoring so that some app
layer packages can now be modularized (including the new packages).

* Domain changes needed per downstream UI changes.

* Add patterns & fixes.

This involves MANY broad changes to ensure consistent string retrieval
(for arrays and plurals), formatting, and string transformations
throughout the codebase. Some extra patterns to added to fix things that
were needed, and a few issues were fixed along the way.

* Add needed domain changes for downstream branch.

Also includes fixing circular dependency issue by splitting out some of
the locale components to be part of utility rather than domain (so that
utiltiy and other packages can depend on MachineLocale).

* Fix regex checks for translated strings.

Also, performance improvements for the regex check.

* Lint-ish fix.

* Fix failing regex checks.

* Add check for nested res subdirectories.

* Clean up locale infra.

Add some other needed functionality.

* Attempt to delete strings to force history.

* Make AAB builds/runs manual-only targets.

* Fix broken tests.

* Fix lint issues & add KDocs.

Also, abstract ContentLocale for consistency & to disallow direct
construction.

* Add 6/11 test suites (& placeholders for other 4).

Silence one file missing a test suite (since it doesn't need one).

Also, some tweaks to the language support definitions.

* Add more test suites for domain layers.

Included introducing a new general purpose utility for testing data
providers + its own test suite.

* Introduce wrapper & fake for bidi wrapping.

Also, add test version of AssetRepository.

Add new placeholder tests & update all tests project-wide to make sure
that they build.

* Add remaining tests.

Included some shadow refactoring, and introducing new test-only
resources.

* Fix Gradle builds.

* Lint fixes.

* Resolve remaining incomplete TODOs.

* Add new codeowners.

* Post-merge fixes.

Make all non-app layer targets build (haven't run tests yet).

Audited existing bidi wrapping cases & converted strings over to being
%s-only.

* Fix most test targets (builds).

All non-app tests confirmed as passing.

* Fix all remaining test builds.

Introduce new TestActivity for scaffolding all non-activity tests.

* Fix all app layer tests.

Add fixes for question player & old answer displaying.

Add fix for guaranteed crash on startup after some changes between now &
the first build of MR3 (dueu to extra updates in
SplashActivityPresenter).

* Fix questions & profile issues.

* Type specifier pattern & fixes.

Address temporary TODO by removing kdoc.

* Add missing KDocs.

* Boilerplate & TODOs for needed tests.

* Add new needed test dep.

Required an update to truth proto lite import (due to an incompatible
update in the common Truth dep).

* Add needed testing coverage.

Other miscellaneous fixes needed to support new tests.

* Two fixes.

1. Introduce proper API compatibility for LocaleController
2. Ensure TranslationController is scoped (breaks test in downstream PR)

* Fix Gradle builds on branch.

* Resolve nearly all pending TODOs.

Only remainder is a test suite whose tests need to be migrated.

* Lint fixes.

* Fix failures found on CI.

* Fix remaining Gradle failures found in CI.

* Post-merge fix.

* Gradle Espresso test fix.

* Deflake DataProviderTestMonitorTest.

* Address reviewer comments.

* Lint fixes.

Co-authored-by: translatewiki.net <[email protected]>
@anandwana001
Copy link
Contributor Author

anandwana001 commented Sep 30, 2021

@BenHenning still issue on latest internal testing live app on Android 11.

@anandwana001 anandwana001 reopened this Sep 30, 2021
@BenHenning
Copy link
Member

@srushtirk also hit this, and I can now repro on an Android 11 device. I was hoping that #3795 would fix this, but I think it primarily fixed #3817. I found that this seems to only occur in the Proguard-optimized version of the app, and the logs are still unhelpful so I'm iterating locally with extra logs in the app to try and investigate. My best guess is that Android 11 (& 12) might be relying on some new reflection that is being stripped out by Proguard (though I'd expect that to trigger a crash, not a hang).

Interestingly, @srushtirk mentioned that MR2 works fine on her Android 11 device so it does seem like this is somehow tied to the splash screen changes (namely that we're now blocking on both language retrieval & onboarding state to proceed). Will keep this thread updated with my findings.

@BenHenning
Copy link
Member

BenHenning commented Oct 1, 2021

Some new notes:

  • Removing the combineWith() & just defaulting the locale doesn't fix anything
  • 1 optimization pass is sufficient to hit the issue (which is nice since it cuts the build time in about 1/3)
  • The app seems to hang immediately after subscribing to the first data provider (interestingly, the LiveData never becomes active nor are any of the constituent data providers processed)

@BenHenning
Copy link
Member

BenHenning commented Oct 1, 2021

FWIW, the comment above regarding Proguard might actually be more likely than at first glance since MR3 is using custom Proguard rules vs. MR2's Gradle (AGP)-generated ones.

Further, Jetpack's Lifecycle relies on some reflection for certain observers (that leverage the annotations). LiveData isn't one of them, but I wonder if something in the Jetpack components library that ties into LiveData does (which could cause a silent failure rather than a crash depending on how it was implemented). Really weird that this wouldn't repro on other versions of Android, though, given AndroidX isn't part of Android.

I'm working to confirm this one way or another now.

Edit: adding exemptions along the lines of https://stackoverflow.com/a/44688917 (but for AndroidX versions) didn't work, so it's probably not the LiveData<->Proguard situation.

@BenHenning
Copy link
Member

Spoke too soon. https://stackoverflow.com/a/59162111 fixes the issue, and I suspect the finding is the actual issue. It seems LifecycleObserver might depend on reflection to verify subscriptions are valid, but it's not clear to me at all why this is an Android 11-specific issue.

@BenHenning
Copy link
Member

BenHenning commented Oct 1, 2021

Aha! This might repro on 28+ per the comment here: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-release/lifecycle/lifecycle-runtime/proguard-rules.pro#18. Just confirming...

Edit: confirming that exact line is the issue (it fixes exactly with that line being present). Simple PR & rebuild coming.

Edit2: for posterity (in case the link above ever breaks), the comment & line of code that fixes this:

# Also this rule prevents registerIn from being inlined.
-keepclassmembers class androidx.lifecycle.ReportFragment$LifecycleCallbacks { *; }```

@BenHenning BenHenning linked a pull request Oct 1, 2021 that will close this issue
6 tasks
BenHenning added a commit that referenced this issue Oct 7, 2021
* Add support for AABs, build flavors, and proguard.

There are a lot of details to cover here--see the PR for the complete
context.

* Lint & codeowner fixes.

* Fix failures.

- Add missing codeowner
- Add support for configuring base branch reference
- Update CI for dev/alpha AAB builds to use 'develop' since there's no
  origin configured by default in the workflows

* Different attempt to fix bad develop reference in CI.

* Initial commit.

This is needed to open a PR on GitHub. This commit is being made so that
the PR can start off in a broken Actions state.

This also initially disables most non-Bazel workflows to make workflow
iteration faster and less impacting on other team members.

* Introduce infrastructure for batching.

This introduces a new mechanism for passing lists of tests to sharded
test targets in CI, and hooks it up. No actual sharding is occurring
yet. This led to some simplifications in the CI workflow since the
script can be more dynamic in computing the full list of targets (which
also works around a previous bug with instrumentation tests being run).
Java proto lite also needed to be upgraded for the scripts to be able to
use it.

More testing/documentation needed as this functionality continues to
expand.

* Add bucketing strategy.

This simply partitions bucketed groups of targets into chunks of 10 for
each run. Only 3 buckets are currently retained to test sharding in CI
before introducing full support.

* Fix caching & stabilize builds.

Fixes some caching bucket and output bugs. Also, introduces while loop &
keep_going to introduce resilience against app test build failures (or
just test failures in general).

* Increase sharding & add randomization.

Also, enable other workflows.

Note that CI shouldn't fully pass yet since some documentation and
testing needs to be added yet, but this is meant to be a more realistic
test of the CI environment before the PR is finished.

* Improving partitionin & readability.

Adds a human-readable prefix to make the shards look a bit nicer.

Also, adds more fine-tuned partitioning to bucket & reduce shard counts
to improve overall timing. Will need to be tested in CI.

* Add new tests & fix static analysis errors.

* Fix script.

A newly computed variable wasn't updated to be used in an earlier
change.

* Fix broken tests & test configuration.

Add docstrings for proto.

* Fix mistake from earlier commit.

* Try 10 max parallel actions instead.

See
#3757 (comment)
for context.

* Fix another error from an earlier commit.

* Localisation updates from https://translatewiki.net.

* Fix mv command so it works on Linux & OSX.

Neither 'mv -t' nor piping to mv work on OSX so we needed to find an
alternative (in this case just trying to move everything). This actually
works a bit better since it's doing a per-file move rather than
accommodating for files that shouldn't be moved (which isn't an issue
since the destination directory is different than the one containing the
AAB file).

* Introduce initial domain layer for translations.

Documentation, thorough tests, and detailed description of these changes
are still needed.

* Initial app layer implementation for translations.

This demonstrates working string selection for system-based and
overwritten app languages, including necessary activity recreation &
layout direction overwriting.

This also includes a bunch of Dagger infra refactoring so that some app
layer packages can now be modularized (including the new packages).

* Domain changes needed per downstream UI changes.

* Add patterns & fixes.

This involves MANY broad changes to ensure consistent string retrieval
(for arrays and plurals), formatting, and string transformations
throughout the codebase. Some extra patterns to added to fix things that
were needed, and a few issues were fixed along the way.

* Add needed domain changes for downstream branch.

Also includes fixing circular dependency issue by splitting out some of
the locale components to be part of utility rather than domain (so that
utiltiy and other packages can depend on MachineLocale).

* Introduce support for content localization.

This includes a bunch of stuff that'll be described in more detail in
the PR description, but it essentially:
- Adds support for displaying content in explorations, questions,
  concept cards, and revision cards in a non-English language
- Adds support for submitting non-English answers
- Updates test structures to validate everything exception questions is
  working for localization

* Fix structures to work with parsing assumptions.

* Fix regex checks for translated strings.

Also, performance improvements for the regex check.

* Lint-ish fix.

* Fix failing regex checks.

* Add check for nested res subdirectories.

* Add remaining regex patterns & fixes.

* Clean up locale infra.

Add some other needed functionality.

* Attempt to delete strings to force history.

* Gate options behind compile-time flag.

Flag status is off by default until #52 is finished.

* Proguard fixes for Glide.

Update version code since 6 & 7 were shipped.

* Make AAB builds/runs manual-only targets.

* Fix broken tests.

* Fix lint issues & add KDocs.

Also, abstract ContentLocale for consistency & to disallow direct
construction.

* Add 6/11 test suites (& placeholders for other 4).

Silence one file missing a test suite (since it doesn't need one).

Also, some tweaks to the language support definitions.

* Add more test suites for domain layers.

Included introducing a new general purpose utility for testing data
providers + its own test suite.

* Introduce wrapper & fake for bidi wrapping.

Also, add test version of AssetRepository.

Add new placeholder tests & update all tests project-wide to make sure
that they build.

* Add remaining tests.

Included some shadow refactoring, and introducing new test-only
resources.

* Fix Gradle builds.

* Lint fixes.

* Resolve remaining incomplete TODOs.

* Add new codeowners.

* Post-merge fixes.

Make all non-app layer targets build (haven't run tests yet).

Audited existing bidi wrapping cases & converted strings over to being
%s-only.

* Fix most test targets (builds).

All non-app tests confirmed as passing.

* Fix all remaining test builds.

Introduce new TestActivity for scaffolding all non-activity tests.

* Fix all app layer tests.

Add fixes for question player & old answer displaying.

Add fix for guaranteed crash on startup after some changes between now &
the first build of MR3 (dueu to extra updates in
SplashActivityPresenter).

* Fix questions & profile issues.

* Type specifier pattern & fixes.

Address temporary TODO by removing kdoc.

* Add missing KDocs.

* Boilerplate & TODOs for needed tests.

* Add new needed test dep.

Required an update to truth proto lite import (due to an incompatible
update in the common Truth dep).

* Add needed testing coverage.

Other miscellaneous fixes needed to support new tests.

* Two fixes.

1. Introduce proper API compatibility for LocaleController
2. Ensure TranslationController is scoped (breaks test in downstream PR)

* Fix Gradle builds on branch.

* Resolve nearly all pending TODOs.

Only remainder is a test suite whose tests need to be migrated.

* Lint fixes.

* Re-add method removed from merge.

* Lint fixes.

This also fixes broken extra/unused imports from the merge.

Verified that the dev build works as of this commit. Haven't verified
anything else.

* Fix compute affected tests script.

Adds support for very large PR changesets.

* Fix failures found on CI.

* Fix remaining Gradle failures found in CI.

* Fix existing domain + app layer tests.

Some reworking was needed in QuestionAssessmentProgressControllerTest.

* Post-merge fix.

* Gradle Espresso test fix.

* Add missing KDocs, remove extra file, and other cleanups.

* Lint fixes.

* Fix CI & lint checks (except regex).

* Deflake DataProviderTestMonitorTest.

* Address reviewer comments.

* Lint fixes.

* Fix affected tests from earlier changes.

These failures were found from CI test workflows.

* Fix remaining Gradle failures.

This introduces a proper fallback mechanism for content strings that
allows Gradle builds & tests to work properly, and adds more robustness
in case misconfigurations actually happen.

* Add placeholders for new needed tests.

* Fix broken tests.

This came from the earlier commit's fix--the suite hadn't been updated.

* Add needed tests for new behaviors.

* Fix Gradle build & mechanism change failures.

* Lint fixes.

* Undo inadvertent change to Gradle jvmargs.

* Disable most tests on Espresso.

* Test fixes + make monitor Espresso-compatible.

* Fix broken tests.

Refactor how platform parameter module.

Add new options fragment tests.

* Add exemptions & regex check tests.

* Lint fixes.

* Lint fixes.

* Add new ratio input rule classifier.

* Fix broken tests (per CI).

* Add mechanism to recover from crashes.

* Remove malformed TODO.

* Add Proguard rules needed to fix splash issue.

See PR & related issue for more context.

* Update LocaleController.kt

Remove TODO on #3800 since it's been resolved.

Co-authored-by: translatewiki.net <[email protected]>
@BenHenning
Copy link
Member

For searching context, this issue was found in 0.6-alpha (MR3).

@BenHenning BenHenning added the Z-ibt Temporary label for Ben to keep track of issues he's triaged. label Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Projects
2 participants