Fix bundled app crash on startup - #1683
Merged
Merged
Conversation
Contributor
Author
|
The test failures aren't related to this PR. They're due to the two servers used in HTTP tests malfunctioning. |
Contributor
|
build |
Contributor
|
Rebuilding with the full-mono-integration-build label so that we can see if the |
Contributor
...because monodroid/master is broken: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/1003/ |
Contributor
|
@grendello: Please rebase this PR on be594d2 or later. |
Fixes: dotnet#1651 Recent update to mono brought in changes in the code generated by `mkbundle` when dealing with AOT. Unfortunately, the changes require the bundle to be able to find the `mono_jit_set_aot_mode` runtime function which isn't exported in the Xamarin.Android up and thus the loading of the bundle crashes on startup with the following message: dlopen failed: cannot locate symbol "mono_jit_set_aot_mode" referenced by libmonodroid_bundle_app.so To fix this we need to augment the bundle's `mono_mkbundle_init` function in generated code to take a third parameter - pointer to the abovementioned function. With the current code this requires a set of rather ugly changes, as seen in this commit, but it makes the application not crash on start and is the fastest way to fix the issue right now. This is a short-term fix, a long-term one will be presented at a later time.
jonpryor
pushed a commit
that referenced
this pull request
May 18, 2018
Fixes: #1651 Recent update to mono (166e7d5) brought in changes in the code generated by `mkbundle.exe`, which is used when `$(BundleAssemblies)`=True. Unfortunately, the changes require the bundle to be able to find the `mono_jit_set_aot_mode()` mono embedding function, which doesn't work because `libmonodroid_bundle_app.so` doesn't link against `libmonosgen-2.0.so` -- because it can't, because on Android e.g. `/data/data/@PACKAGE_NAME@/lib` isn't in `$LD_LIBRARY_PATH`, meaning libraries "next to" `libmonodroid_bundle_app.so` won't be found by **dlopen**(3), which is a constant source of ironically great fun -- which means that when we *do* try to call `dlopen("libmonodroid_bundle_app")`, *it fails*: dlopen failed: cannot locate symbol "mono_jit_set_aot_mode" referenced by libmonodroid_bundle_app.so To fix this we need to augment the bundle's `mono_mkbundle_init()` function (which comes in via generated code) to take a third parameter: a function pointer to `mono_jit_set_aot_mode`. With the current code this requires a set of rather ugly changes, but it makes the application not crash on start and is the fastest way to fix the issue right now. This is a short-term fix. A longer-term fix is being worked on: mono/mono#8742 Additionally, update `RunTests.targets` so that we build `src/Mono.Android/Test` with `$(BundleAssemblies)`=True and execute the resulting `Mono.Android_Tests-Signed.apk` on the emulator to ensure that `$(BundleAssemblies)`=True support works into the future.
radekdoulik
added a commit
to radekdoulik/xamarin-android
that referenced
this pull request
Nov 7, 2018
Fixes dotnet#2400 With dotnet#1683 we started to run and measure the apk tests with `BundleAssemblies=True` as well. To not mix and repeast these measurements with other ones, introduce `TestsFlavor` property in place of `TestsAotName` to distinguish the apk tests runs when collecting and processing measurements data. It is similar to what we did with AOT before. Example content of TestResult-Mono.Android_Tests-times.csv after the fix: last-Release,JNI.init-Release,init-Release,NUnit.results-Release,last-Release-Aot,JNI.init-Release-Aot,init-Release-Aot,NUnit.results-Release-Aot,last-Release-Bundle,JNI.init-Release-Bundle,init-Release-Bundle,NUnit.results-Release-Bundle 518,116,116,8347,647,86,86,7670,755,159,159,8416
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes: #1651
Recent update to mono brought in changes in the code generated by
mkbundlewhen dealing with AOT. Unfortunately, the changes require the bundle to be able
to find the
mono_jit_set_aot_moderuntime function which isn't exported in theXamarin.Android up and thus the loading of the bundle crashes on startup with
the following message:
To fix this we need to augment the bundle's
mono_mkbundle_initfunction ingenerated code to take a third parameter - pointer to the abovementioned
function. With the current code this requires a set of rather ugly changes, as
seen in this commit, but it makes the application not crash on start and is the
fastest way to fix the issue right now.
This is a short-term fix, a long-term one will be presented at a later time.