From 311af6799acbf971cc0203b7a729ea192d9f249d Mon Sep 17 00:00:00 2001 From: devthejo Date: Sat, 27 Sep 2025 12:12:20 +0200 Subject: [PATCH] fix(android): 16k issue wip --- android/app/build.gradle | 7 ++- android/app/src/main/AndroidManifest.xml | 7 ++- .../com/alertesecours/FrescoInitProvider.kt | 49 +++++++++++++++++++ .../java/com/alertesecours/MainApplication.kt | 6 +-- ios/AlerteSecours.xcodeproj/project.pbxproj | 37 +++++++++++++- 5 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 android/app/src/main/java/com/alertesecours/FrescoInitProvider.kt diff --git a/android/app/build.gradle b/android/app/build.gradle index b8fe628..112580a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -170,7 +170,7 @@ configurations.all { // Force Fresco/FBJNI versions with 16KB page support (or newer) force "com.facebook.fresco:fresco:3.6.0" force "com.facebook.fresco:imagepipeline:3.6.0" - force "com.facebook.fresco:imagepipeline-native:3.6.0" + force "com.facebook.fresco:imagepipeline-base:3.6.0" force "com.facebook.fresco:gifdecoder:3.6.0" force "com.facebook.fresco:nativeimagetranscoder:3.6.0" force "com.facebook.fresco:static-webp:3.6.0" @@ -184,7 +184,6 @@ configurations.all { exclude group: "com.huawei.hms", module: "ucs-credential-developers" exclude group: "com.huawei.hms.LocationLiteSdk", module: "core" // Exclude Fresco native pipeline and webp natives to drop 0x1000 .so files - exclude group: "com.facebook.fresco", module: "imagepipeline-native" } dependencies { @@ -193,6 +192,10 @@ dependencies { // Ensure Fresco core API available for app-level initialization (MainApplication) implementation("com.facebook.fresco:fresco:3.6.0") + // Ensure MemoryChunkType and related API are available + implementation("com.facebook.fresco:imagepipeline-base:3.6.0") + // Include native pipeline so libimagepipeline.so is present (3.6.0 expected 16KB aligned) + implementation("com.facebook.fresco:imagepipeline-native:3.6.0") def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true"; def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true"; diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8a977a7..90d9ed4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -79,5 +79,10 @@ + - \ No newline at end of file + diff --git a/android/app/src/main/java/com/alertesecours/FrescoInitProvider.kt b/android/app/src/main/java/com/alertesecours/FrescoInitProvider.kt new file mode 100644 index 0000000..8cbccc9 --- /dev/null +++ b/android/app/src/main/java/com/alertesecours/FrescoInitProvider.kt @@ -0,0 +1,49 @@ +package com.alertesecours + +import android.content.ContentProvider +import android.content.ContentValues +import android.database.Cursor +import android.net.Uri +import com.facebook.drawee.backends.pipeline.Fresco +import com.facebook.imagepipeline.core.ImagePipelineConfig + +/** + * Initializes Fresco as early as possible (before Application.onCreate), + * with native code disabled so no libimagepipeline.so is ever requested. + * + * This prevents crashes on devices enforcing 16KB page size when the native + * Fresco pipeline is not packaged. + */ +class FrescoInitProvider : ContentProvider() { + + override fun onCreate(): Boolean { + val ctx = context ?: return false + + // Use default (native) pipeline; libimagepipeline.so is now packaged (3.6.0, 16KB aligned) + val config = ImagePipelineConfig.newBuilder(ctx).build() + + Fresco.initialize(ctx, config) + return true + } + + override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String? + ): Cursor? = null + + override fun getType(uri: Uri): String? = null + + override fun insert(uri: Uri, values: ContentValues?): Uri? = null + + override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int = 0 + + override fun update( + uri: Uri, + values: ContentValues?, + selection: String?, + selectionArgs: Array? + ): Int = 0 +} diff --git a/android/app/src/main/java/com/alertesecours/MainApplication.kt b/android/app/src/main/java/com/alertesecours/MainApplication.kt index 8e395f0..ece8f34 100644 --- a/android/app/src/main/java/com/alertesecours/MainApplication.kt +++ b/android/app/src/main/java/com/alertesecours/MainApplication.kt @@ -35,6 +35,7 @@ class MainApplication : Application(), ReactApplication { override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED + } ) @@ -45,11 +46,6 @@ class MainApplication : Application(), ReactApplication { super.onCreate() SoLoader.init(this, OpenSourceMergedSoMapping) - // Initialize Fresco to avoid native memory chunk (no libimagepipeline.so load) - val builder = ImagePipelineConfig.newBuilder(this) - builder.experiment().setNativeCodeDisabled(true) - val frescoConfig = builder.build() - Fresco.initialize(this, frescoConfig) if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // If you opted-in for the New Architecture, we load the native entry point for this app. diff --git a/ios/AlerteSecours.xcodeproj/project.pbxproj b/ios/AlerteSecours.xcodeproj/project.pbxproj index 58c9e4a..8cbcbac 100644 --- a/ios/AlerteSecours.xcodeproj/project.pbxproj +++ b/ios/AlerteSecours.xcodeproj/project.pbxproj @@ -179,7 +179,8 @@ D8ED2FC173D1461F87CDF597 /* Fix Xcode 15 Bug */, F3F5A8D7A73545D78A4D8467 /* Fix Xcode 15 Bug */, BC7FCBEF8C354C749AB11067 /* Fix Xcode 15 Bug */, - FA5F247997BA4DDBB06F01B8 /* Remove signature files (Xcode workaround) */, + 59A6E29E61A94EC98E5B50A7 /* Fix Xcode 15 Bug */, + 822458BA69944A72BCDBEB3B /* Remove signature files (Xcode workaround) */, ); buildRules = ( ); @@ -1136,6 +1137,40 @@ fi"; shellScript = " echo \"Remove signature files (Xcode workaround)\"; rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\"; + "; + }; + 59A6E29E61A94EC98E5B50A7 /* Fix Xcode 15 Bug */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + name = "Fix Xcode 15 Bug"; + inputPaths = ( + ); + outputPaths = ( + ); + shellPath = /bin/sh; + shellScript = "if [ \"$XCODE_VERSION_MAJOR\" = \"1500\" ]; then + echo \"Remove signature files (Xcode 15 workaround)\" + find \"$BUILD_DIR/${CONFIGURATION}-iphoneos\" -name \"*.signature\" -type f | xargs -r rm +fi"; + }; + 822458BA69944A72BCDBEB3B /* Remove signature files (Xcode workaround) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + name = "Remove signature files (Xcode workaround)"; + inputPaths = ( + ); + outputPaths = ( + ); + shellPath = /bin/sh; + shellScript = " + echo \"Remove signature files (Xcode workaround)\"; + rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\"; "; }; /* End PBXShellScriptBuildPhase section */