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

lyra_android_example.apk crashed. #147

Open
TangYuFan opened this issue Jul 8, 2024 · 6 comments
Open

lyra_android_example.apk crashed. #147

TangYuFan opened this issue Jul 8, 2024 · 6 comments

Comments

@TangYuFan
Copy link

Hello, the Android example compiled according to the readme file runs well on some phones and crashes on some phones。

The compilation script I tried:
(1) bazel build -c opt lyra/android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK
(2) bazel build -c opt lyra/android_example:lyra_android_example --fat_apk_cpu=armeabi-v7a,arm64-v8a --copt=-DBENCHMARK

Running apk on some phones has crashed. The following is the error log:
image

May I ask how to solve the above problems? Is compiling a script requiring special instructions? Because I use encoding and decoding interfaces to package it into SO for Android phones, some phones may not run properly。

@JianhaoPeng
Copy link

@TangYuFan Hi, I also encountered this problem, have you solved this yet? I tried upgrade the version of sdk, but the compiling process failed, only version 30 can build successfully. Besides, is this apk can be adapted to android 15? Thank you so much.

@TangYuFan
Copy link
Author

My colleague solved this problem, probably because there is an issue with the destructor:
6b9bfc087a008363defb72bebfcf682d

@JianhaoPeng
Copy link

JianhaoPeng commented Sep 4, 2024

@TangYuFan Hi, thanks, I found this line in DenseStorge.h, should I comment out this line, can you tell me how do you solve this? By the way, I found that the app didn't crash after I commented out the encode and decode methods in jni_lyra_benchmark_lib.cpp. Can we use email to discuss it, i struggle with this problem for weeks, my email is [email protected], thanks a million.

@TangYuFan
Copy link
Author

My colleague found through GDB debugging that it is hanging on this destructor. Sorry, I don't know the specific modifications. My algorithm colleague fixed the problem and directly provided me with the .so dynamic library file.

@JianhaoPeng
Copy link

We're trying to implement the encode and decode method separately using the .so dynamic library file, can you share it? Really appreciate your help.

@TangYuFan
Copy link
Author

You can obtain the Android SO library file through the following methods:
The idea comes from another issue
image

  1. Add codec dependency to android_example / BUILD
    deps = [
    "//lyra:lyra_encoder",
    "//lyra:lyra_decoder",
    ]
    2.Add the codec jni function to jni_lyra_benchmarked_lib.cc

#include "lyra/lyra_encoder.h"
#include "lyra/lyra_decoder.h"

namespace {
std::unique_ptrchromemedia::codec::LyraEncoder encoder;
std::unique_ptrchromemedia::codec::LyraDecoder decoder;
}

Next, you can call Lyra to provide JNI functions such as initialization, release, encoding, decoding, etc
like this:
extern "C" JNIEXPORT int JNICALL Java_com_lyra_LyraCodec_codecInit(JNIEnv* env, jobject this_obj, jint sampleRateHz, jint numChannels, jint bitrate, jboolean enableDtx, jstring modelPath){
const char* modelPathCStr = env->GetStringUTFChars(modelPath, nullptr);
if (modelPathCStr == nullptr) {
return 0;
}
ghc::filesystem::path model(modelPathCStr);
env->ReleaseStringUTFChars(modelPath, modelPathCStr);
encoder = chromemedia::codec::LyraEncoder::Create(sampleRateHz, numChannels, bitrate, enableDtx, model);
decoder = chromemedia::codec::LyraDecoder::Create(sampleRateHz, numChannels, model);
return (encoder != nullptr) && (decoder != nullptr);
}
3. Compile android_deample and extract so file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants