Repository navigation
Android: use system-provided image decoding + encoding - #7828
Conversation
|
@kkaefer, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @zugaldia and @1ec5 to be potential reviewers. |
9a696ac to
8df51f1
Compare
|
Implementing a native InputStream also requires a copy. |
rationale: encodePNG is only used in tests + sample apps, but shouldn't actually be part of the core library. In #7828, we're removing the libpng dependency for Android, and using a libpng-free version of encodePNG allows us to run the core unit tests on Android without pulling in libpng just for the test suite. In a next step, we should remove encodePNG() from the image.hpp header, which is a public header.
|
Decoding part looks good. For the encoding part, I like the solution in #7813 better, given that it is only used in tests. |
|
@jfirebaugh yeah, plan is to get #7318 in first, then remove encoding from this PR. |
rationale: encodePNG is only used in tests + sample apps, but shouldn't actually be part of the core library. In #7828, we're removing the libpng dependency for Android, and using a libpng-free version of encodePNG allows us to run the core unit tests on Android without pulling in libpng just for the test suite. In a next step, we should remove encodePNG() from the image.hpp header, which is a public header.
8df51f1 to
39ce9bb
Compare
…set up an Android runtime environment Instead of mocking android.util.Log, we're registering the real libraries so that we can use the full runtime environment
39ce9bb to
883e46c
Compare
|
Read for review |
| // We're declaring the function, which is libandroid_runtime.so. | ||
| // It is defined in AndroidRuntime.cpp: | ||
| // https://github.com/android/platform_frameworks_base/blob/master/core/jni/AndroidRuntime.cpp | ||
| // Once this symbol goes away, we'll have to revisit. |
There was a problem hiding this comment.
If this symbol goes away, the Mapbox GL SDK will start failing, right? It would be worse than a build time failure -- existing installations might stop working after an OS or software upgrade.
If this is not a public API, let's find a different way.
There was a problem hiding this comment.
This file is not part of the SDK; it is only used to bootstrap the core unit tests (with Google Test). If this symbol went away, the only thing that would break is launching the unit tests, but it does not impact in any way the function of a deployed version of Mapbox GL.
I've checked the past couple of Android versions and this symbol remained stable from (at least) 4.4 to 7.0.
Another take at #7329.
libjpeg-turboandlibpngin favor of calls toBitmapFactory.decodeByteArray. We're doing a bunch of copies, but I don't think we can avoid any of them. I implemented a version that usedjava.nio.ByteBufferand supplying the pointer address directly, but Java can't generate abyte[]required fordecodeByteArray. We could alternatively implement aNativeInputStream(similar to theNativeOutputStreamcontained in this PR) and useBitmapFactory.decodeStreamto avoid one copy. We are doing a second copy from the decoded Bitmap object to memory we manage ourselves (usinglibjnigraphics. Instead, we could completely replaceutil::Imagefor android builds with a version that keeps around theBitmapobject and keeps the pixels locked so they don't go away.Bitmapobject right away. Instead, we're now directly converting the raw C++PremultipliedImageto a JavaBitmapobject. This reduces the snapshotting time on my test device from ~550ms to ~80ms.Build size for Release/arm-v8 drops from 5620 KB to 5259 KB.
Fixes #7329, #6238.