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

When building via App Bundle, Fresco fails to find "libimagepipeline.so" #2253

Closed
icerfish opened this issue Dec 7, 2018 · 21 comments
Closed

Comments

@icerfish
Copy link

icerfish commented Dec 7, 2018

Description

When launching an Activity that uses Fresco, which has been generated via Android App Bundle, it fails to find "libimagepipeline.so" and crashes the application.

Reproduction

  1. Create a sample application that uses Fresco
  2. Generate a signed Bundle
  3. Using Bundle Tool build the APKs from the Bundle
  4. Using Bundle Tool, install the APK on to your device
  5. Navigate to Activity where Fresco is initialised
  6. Observe crash

Solution

I originally thought this might have been an issue with minify, R8, or Proguard, but I disabled all of those, and still observed the same result when building via App Bundle.

I have tested other components of my app that also use native libraries, but they all operate as expected, only with Fresco struggling to load the respective binary.

A temporary, but not ideal solution I found is disabling splitting of APK's by abi using the following configuration, but including all the binaries results in a significantly larger APK size.

android {
    // Rest of your configuration here
    
    bundle {
        abi {
            enableSplit false
        }
    }
}

Additional Information

  • Fresco version: 1.10.0
  • Platform version: Samsung SM-G955F, Android 8.0.0
@KimiChiu
Copy link

Does your error message looks like this one? #2049

@icerfish
Copy link
Author

icerfish commented Dec 11, 2018 via email

@lambdapioneer
Copy link
Contributor

Hi @icerfish,

Thank you for filing this issue with all the required details (maybe add a paste of the error if you have time). I can imagine that Fresco might not fully support app bundles and I do not think that we have ever tested the interplay.

I will mark this as a "bug" and "help-wanted" hoping that this is something the open-source community can help us with.

@icerfish
Copy link
Author

icerfish commented Dec 11, 2018

Hi @lambdapioneer,

Here is the stacktrace:

    Process: com.gobuzzvault.android, PID: 17499
    java.lang.NoClassDefFoundError: com.facebook.imagepipeline.memory.NativeMemoryChunk
        at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(NativeMemoryChunkPool.java:25)
        at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(NativeMemoryChunkPool.java:13)
        at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:267)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.<init>(MemoryPooledByteBufferOutputStream.java:51)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:73)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:24)
        at com.facebook.imagepipeline.producers.LocalFetchProducer.getByteBufferBackedEncodedImage(LocalFetchProducer.java:87)
        at com.facebook.imagepipeline.producers.LocalFetchProducer.getEncodedImage(LocalFetchProducer.java:99)
        at com.facebook.imagepipeline.producers.LocalContentUriFetchProducer.getCameraImage(LocalContentUriFetchProducer.java:100)
        at com.facebook.imagepipeline.producers.LocalContentUriFetchProducer.getEncodedImage(LocalContentUriFetchProducer.java:76)
        at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:52)
        at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:48)
        at com.facebook.common.executors.StatefulRunnable.run(StatefulRunnable.java:43)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:51)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libimagepipeline.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
        at com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader.load(ImagePipelineNativeLoader.java:40)
        at com.facebook.imagepipeline.memory.NativeMemoryChunk.<clinit>(NativeMemoryChunk.java:31)
        at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(NativeMemoryChunkPool.java:25)
        at com.facebook.imagepipeline.memory.NativeMemoryChunkPool.alloc(NativeMemoryChunkPool.java:13)
        at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:267)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream.<init>(MemoryPooledByteBufferOutputStream.java:51)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:73)
        at com.facebook.imagepipeline.memory.MemoryPooledByteBufferFactory.newByteBuffer(MemoryPooledByteBufferFactory.java:24)
        at com.facebook.imagepipeline.producers.LocalFetchProducer.getByteBufferBackedEncodedImage(LocalFetchProducer.java:87)
        at com.facebook.imagepipeline.producers.LocalFetchProducer.getEncodedImage(LocalFetchProducer.java:99)
        at com.facebook.imagepipeline.producers.LocalContentUriThumbnailFetchProducer.getThumbnail(LocalContentUriThumbnailFetchProducer.java:135)
        at com.facebook.imagepipeline.producers.LocalContentUriThumbnailFetchProducer.getCameraImage(LocalContentUriThumbnailFetchProducer.java:100)
        at com.facebook.imagepipeline.producers.LocalContentUriThumbnailFetchProducer.getEncodedImage(LocalContentUriThumbnailFetchProducer.java:75)
        at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:52) 
        at com.facebook.imagepipeline.producers.LocalFetchProducer$1.getResult(LocalFetchProducer.java:48) 
        at com.facebook.common.executors.StatefulRunnable.run(StatefulRunnable.java:43) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:51) 
        at java.lang.Thread.run(Thread.java:764)

It looks similar to issues that others are having.

From looking around the codebase, it looks like this isn't an issue with Fresco itself, but more the SoLoader library. I will cross post the issue over to that repository, and workload allowing dedicate some time to try work out what is the issue exactly.

@beatrizz
Copy link

Hi, I had the same issue when using app bundles, as described in #2049 (comment)

Using Fresco 1.11 and setting .experiment().setNativeCodeDisabled(true) in Fresco's ImagePipelineConfig made static images work for me but GIFs crashed with a different stacktrace, which looked like the same SoLoader issue with a different library. @icerfish , this may help you if you're not using GIFs.

@nesterov-n
Copy link
Contributor

nesterov-n commented Dec 28, 2018

I have found out an issue in SoLoader lib used by Fresco. I have prepared PR with a fix: facebook/SoLoader#26
That fix makes fresco works fine with app bundle.
I have published the patched version of SoLoader lib. You can use it in your project if you can't wait till PR is merged.

repositories {
    maven {
        url  "https://dl.bintray.com/nnesterov/maven" 
    }
}

compile('com.facebook.fresco:fresco:1.10.0') {
    exclude group: 'com.facebook.soloader', module: 'soloader'
}
compile("com.avito.android:patched-soloader:0.1.0")

@nesterov-n
Copy link
Contributor

The previous version of patched-soloader didn't work on pre-lollipop devices. I've fixed it. Use
compile("com.avito.android:patched-soloader:0.1.1")

@theromis
Copy link

@nesterov-n thanks for great fix, any progress to integrate it into fresco?

@sailesh2
Copy link

@nesterov-n i am also facing the same issue. please let me know when will it be integrated into fresco?

@nesterov-n
Copy link
Contributor

nesterov-n commented Jan 21, 2019

Hi @theromis and @sailesh2
I don't work at Facebook (it's so sad). I'm just a Fresco user but I couldn't wait for a fix. So I had to debug it and fix.
Currently, I use the patched version of soloder lib for my project as I described in the comment above. Most recent version is com.avito.android:patched-soloader:0.1.2

My PR to soloader lib is being reviewed now but soloader maintainer tells that there is no estimation of new soloader lib release. So It's impossible to estimate when Fresco will use this new version.

If it's urgent you can use my patched version. We published bundle with fresco to production. Works well.

@luizguilhermefr
Copy link

Cannot figure out why isn't this workaround integrated into Fresco yet.

@oprisnik
Copy link
Contributor

We've landed the SoLoader fix. We'll release a new Fresco version soon once the SoLoader version has been released.

@iwo
Copy link

iwo commented Jan 29, 2019

@oprisnik what's the ETA for the releases? I get that it requires coordination of 2 teams but at least some rough number would help many developers decide if they should apply workaround above or wait for the release.

@oprisnik oprisnik reopened this Jan 29, 2019
@oprisnik
Copy link
Contributor

oprisnik commented Jan 29, 2019

SoLoader v0.6.0 has just been released and I've updated the Fresco dependency (6fc071d). We want to wait for the MIT licensed Bolts release (#2257). If that release takes longer than expected, we are going to skip it for now and release without that. In any case, the new version should be out in a couple of days.

@luizguilhermefr
Copy link

I don't want to be dull, but shouldn't fresco be released? Seems that this issue you pointed out hasn't received any activity for a while.

@oprisnik
Copy link
Contributor

oprisnik commented Feb 4, 2019

We just released version 1.12.0 that includes the fixed SoLoader version.

@oprisnik oprisnik closed this as completed Feb 4, 2019
@ProHzen
Copy link

ProHzen commented Feb 26, 2019

try add proguard

Do not strip any method/class that is annotated with @DoNotStrip

-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.common.internal.DoNotStrip *;
}

Do not strip any method/class that is annotated with @DoNotOptimize

-keep @com.facebook.soloader.DoNotOptimize class *
-keepclassmembers class * {
@com.facebook.soloader.DoNotOptimize *;
}

Keep native methods

-keepclassmembers class * {
native ;
}

-dontwarn okio.**
-dontwarn com.squareup.okhttp.**
-dontwarn okhttp3.**
-dontwarn javax.annotation.**
-dontwarn com.android.volley.toolbox.**
-dontwarn com.facebook.infer.**

@samyakjain
Copy link

@ProHzen Has this fixed the soloader crash ?

@ProHzen
Copy link

ProHzen commented Jul 30, 2019

Yes, I solved it.

@ishroid
Copy link

ishroid commented Sep 13, 2019

it is still in fresco 2.0.0, :-( , please suggest workaround i only have issue with nexus devices

@funnyzhaov
Copy link

@ProHzen Hello, can you send me your confusion list?I tried it the way you did, but it didn't work.
Info:
fresco:1.13.0
classpath 'com.android.tools.build:gradle:3.5.1'

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

Successfully merging a pull request may close this issue.