Add 16 KB page support for decoder extensions on Android 15

We need to rebuild any native components of the app to prevent crashes on devices with 16 KB page support.

Tested on a device that supports 16 KB pages and runs Android 15, as well as on older Android devices.

Issue: androidx/media#1685
PiperOrigin-RevId: 684488244
This commit is contained in:
rohks 2024-10-10 10:15:38 -07:00 committed by Copybara-Service
parent 6acddfeee6
commit 2640ebd58f
13 changed files with 71 additions and 1 deletions

View File

@ -145,6 +145,8 @@
* Fix user info removal for URLs that contain encoded @ characters * Fix user info removal for URLs that contain encoded @ characters
([#1138](https://github.com/androidx/media/pull/1138)). ([#1138](https://github.com/androidx/media/pull/1138)).
* Decoder Extensions (FFmpeg, VP9, AV1, etc.): * Decoder Extensions (FFmpeg, VP9, AV1, etc.):
* Add 16 KB page support for decoder extensions on Android 15
([#1685](https://github.com/androidx/media/issues/1685)).
* MIDI extension: * MIDI extension:
* Leanback extension: * Leanback extension:
* Cast Extension: * Cast Extension:

View File

@ -27,6 +27,14 @@ android {
} }
} }
} }
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
} }
// Configure the native build only if libgav1 is present to avoid gradle sync // Configure the native build only if libgav1 is present to avoid gradle sync

View File

@ -61,3 +61,7 @@ target_link_libraries(gav1JNI
PRIVATE libgav1_static PRIVATE libgav1_static
PRIVATE ${android_log_lib}) PRIVATE ${android_log_lib})
# Enable 16 KB ELF alignment.
target_link_options(gav1JNI
PRIVATE "-Wl,-z,max-page-size=16384")

View File

@ -13,7 +13,17 @@
// limitations under the License. // limitations under the License.
apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle" apply from: "$gradle.ext.androidxMediaSettingsDir/common_library_config.gradle"
android.namespace = 'androidx.media3.decoder.ffmpeg' android {
namespace 'androidx.media3.decoder.ffmpeg'
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}
// Configure the native build only if ffmpeg is present to avoid gradle sync // Configure the native build only if ffmpeg is present to avoid gradle sync
// failures if ffmpeg hasn't been built according to the README instructions. // failures if ffmpeg hasn't been built according to the README instructions.

View File

@ -56,3 +56,7 @@ target_link_libraries(ffmpegJNI
if(ANDROID_ABI STREQUAL "arm64-v8a") if(ANDROID_ABI STREQUAL "arm64-v8a")
target_link_options(ffmpegJNI PRIVATE "-Wl,-Bsymbolic") target_link_options(ffmpegJNI PRIVATE "-Wl,-Bsymbolic")
endif() endif()
# Enable 16 KB ELF alignment.
target_link_options(ffmpegJNI
PRIVATE "-Wl,-z,max-page-size=16384")

View File

@ -23,6 +23,14 @@ android {
} }
androidTest.assets.srcDir '../test_data/src/test/assets' androidTest.assets.srcDir '../test_data/src/test/assets'
} }
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
} }
dependencies { dependencies {

View File

@ -35,4 +35,6 @@ LOCAL_CFLAGS += -D_REENTRANT -DPIC -DU_COMMON_IMPLEMENTATION -fPIC -DHAVE_SYS_PA
LOCAL_CFLAGS += -O3 -funroll-loops -finline-functions -DFLAC__NO_ASM '-DFLAC__HAS_OGG=0' LOCAL_CFLAGS += -O3 -funroll-loops -finline-functions -DFLAC__NO_ASM '-DFLAC__HAS_OGG=0'
LOCAL_LDLIBS := -llog -lz -lm LOCAL_LDLIBS := -llog -lz -lm
# Enable 16 KB ELF alignment.
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@ -27,6 +27,14 @@ android {
} }
} }
} }
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
} }
// Configure the native build only if libiamf is present to avoid gradle sync // Configure the native build only if libiamf is present to avoid gradle sync

View File

@ -44,3 +44,7 @@ target_link_libraries(iamfJNI
PRIVATE android PRIVATE android
PRIVATE iamf PRIVATE iamf
PRIVATE ${android_log_lib}) PRIVATE ${android_log_lib})
# Enable 16 KB ELF alignment.
target_link_options(iamfJNI
PRIVATE "-Wl,-z,max-page-size=16384")

View File

@ -23,6 +23,14 @@ android {
} }
androidTest.assets.srcDir '../test_data/src/test/assets' androidTest.assets.srcDir '../test_data/src/test/assets'
} }
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
} }
dependencies { dependencies {

View File

@ -30,4 +30,6 @@ LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES := opus_jni.cc LOCAL_SRC_FILES := opus_jni.cc
LOCAL_LDLIBS := -llog -lz -lm LOCAL_LDLIBS := -llog -lz -lm
LOCAL_STATIC_LIBRARIES := libopus LOCAL_STATIC_LIBRARIES := libopus
# Enable 16 KB ELF alignment.
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@ -23,6 +23,14 @@ android {
} }
androidTest.assets.srcDir '../test_data/src/test/assets' androidTest.assets.srcDir '../test_data/src/test/assets'
} }
// TODO(Internal: b/372449691): Remove packagingOptions once AGP is updated
// to version 8.5.1 or higher.
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
} }
dependencies { dependencies {

View File

@ -32,6 +32,8 @@ LOCAL_SRC_FILES := vpx_jni.cc
LOCAL_LDLIBS := -llog -lz -lm -landroid LOCAL_LDLIBS := -llog -lz -lm -landroid
LOCAL_SHARED_LIBRARIES := libvpx LOCAL_SHARED_LIBRARIES := libvpx
LOCAL_STATIC_LIBRARIES := cpufeatures LOCAL_STATIC_LIBRARIES := cpufeatures
# Enable 16 KB ELF alignment.
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures) $(call import-module,android/cpufeatures)