Open ToxicBakery opened 6 years ago
I just tested the flight plan, i actually scrolled through both viewers got to about 400mb of memory then removed and my memory recovered to where i started, didnt find any issues with it unless i wasnt looking hard enough..
That's the leak though right? Those images are not being held reference by the cache they are orphaned and seemingly held by the native code or am I missing something? For comparison opening the same document via drive or a web browser on the same devices does not cause 400+ MB of usage so something isn't quite right.
I'm using a lot of memory due to the smaller images as shown in the images so in effect I'm loading the document twice hence the 300mb over the norm. I haven't looked to see what memory is used on a pc as a comparison but the pdf is built from images and not text so it would be large and consume lots of memory.
I open large drawings in pdf they take a while to open but don't believe I get any memory issues but like I said I haven't looked to deep into it.
@ToxicBakery Android uses Garbage Collector, when items are removed from cache it doesn't mean that they will be removed from memory immediately
I found that if you open a large pdf file, opened pages would cost much memory.So I manage opened pages with LruCache, and call closePage() in time, it works fine. You should add closePage() for PdfiumCore by yourself.
Bit late to the party but adding onto what xybean suggested, I found that you can also use a queue system which will automatically truncate opened pages once they've reached a certain amount. This is particularly helpful on devices with low memory.
After several attempts including that of adjusting values within the Constants.java file regarding caching limits with no discernible effects, I did the following:
I forked PdfiumAndroid from barteksc and added the closePage() function as suggested by xybean. You can find an example on his github page.
From there, forked the AndroidPDFViewer project by barteksc and added a const variable MAX_PAGES to the PdfFile class. I found that 10 pages gave me acceptable results of around 178mbs at peak memory usage, never going further. My document was relatively graphic intensive being lecture slides and notes, but your mileage may vary with different PDFs. Different pages with different content will yield different memory requirements hence, you'll have to play with this.
Declare an integer queue: Queue
Finally, within the openPage() function inside the PdfFile Class, add the queue truncation logic. Mine went something like this:
public boolean openPage(int pageIndex) throws PageRenderingException {
int docPage = documentPage(pageIndex);
if (docPage < 0) {
return false;
}
synchronized (lock) {
if (openedPages.indexOfKey(docPage) < 0) {
try {
pdfiumCore.openPage(pdfDocument, docPage);
openedPages.put(docPage, true);
// Memory management
OpenedPageQueue.add(pageIndex);
if(OpenedPageQueue != null)
{
if(OpenedPageQueue.size() > MAX_PAGES)
{
int oldPage = OpenedPageQueue.poll();
pdfiumCore.closePage(this.pdfDocument, oldPage);
openedPages.delete(oldPage);
}
}
return true;
} catch (Exception e) {
openedPages.put(docPage, false);
throw new PageRenderingException(pageIndex, e);
}
}
return false;
}
}
It feels a bit hacky to me but it gets the job done nevertheless. I haven't had any issues with leaks using this and rendering seems to be okay albeit a bit slow. Hope this helps anyone who's ran into the same issue.
Edit:
Out of curiosity, I tested the Flight plan PDF and I seem to be getting a consistent 50mbs-60mbs peak despite spamming the scroll/page change functions. For anyone who's curious, the hardware I'm using is a Lenovo TBX103F with Android 6.1 and 1GB RAM.
@HaiYoAshCrow Hi, i can't find the function "closePage" on his github page.Can you tell me where? Thank you!
@yuquan23459 See: https://github.com/xybean/PdfiumAndroid/blob/master/src/main/java/com/shockwave/pdfium/PdfiumCore.java
Do a text search for closePage(PdfDocument doc, int pageIndex).
@HaiYoAshCrow Thank you first! I have forked PdfiumAndroid from xybean,but no maven.properties in project.Then AndroidStudio will report error!
@yuquan23459 It's my personal file used for maven repository, so I haven't upload it. You just need to delete the relevant code.
@yuquan23459 I used barteksc's pdfium and referenced the pdfium subproject in my own project alongside the AndroidPdfViewer as modules. I had issues with the maven plugin which was resolved by adding classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' to the pdfium's build.gradle.
My pdfium's build gradle is as follows with modifications for :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven'
bintrayName = 'pdfium-android'
publishedGroupId = 'com.github.barteksc'
libraryName = 'PdfiumAndroid'
artifact = 'pdfium-android'
libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap'
siteUrl = 'https://github.com/barteksc/PdfiumAndroid'
gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'
libraryVersion = '1.8.2'
developerId = 'barteksc'
developerName = 'Bartosz Schiller'
developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.8.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets{
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:25.3.1'
}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
@xybean I annotate some code in build.gradle, now the build.gradle like this: buildscript { repositories { jcenter() }
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
}
apply plugin: 'com.android.library'
// ext { // GROUP = 'com.egeio.preview' // VERSION = '1.0.2-SNAPSHOT' // TEST = false
// TEST_REPO = '../repo'
// Properties properties = new Properties() // properties.load(project.rootProject.file('maven.properties').newDataInputStream())
// RELEASE_URL = properties.getProperty("RELEASE_URL") // SNAPSHOT_URL = properties.getProperty("SNAPSHOT_URL") // USER_NAME = properties.getProperty("USER_NAME") // PASSWORD = properties.getProperty("PASSWORD") // }
android { compileSdkVersion 25 buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.8.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:25.3.1' }
// apply from: 'maven.gradle'
But now it will failed when i open the pdf,the log is: 03-16 16:04:20.209 5790-8186/com.example.wyq.docopenctl E/art: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) 03-16 16:04:20.286 5790-5790/com.example.wyq.docopenctl E/PDFView: load pdf error java.lang.UnsatisfiedLinkError: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method) at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:139) at com.github.barteksc.pdfviewer.source.FileSource.createDocument(FileSource.java:38) at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49) at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 03-16 16:04:22.328 2707-2707/com.android.phone E/CarrierConfigLoader: Failed to get package version for: com.android.carrierconfig 03-16 16:04:32.165 2707-10519/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: No UICC 03-16 16:04:32.287 2707-32248/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.295 2707-29496/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.317 2707-3336/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.323 2707-2707/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.335 2707-2707/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.341 2707-2707/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.352 2707-2707/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty. 03-16 16:04:32.381 2707-2707/com.android.phone E/PhoneInterfaceManager: [PhoneIntfMgr] getIccId: ICC ID is null or empty.
@HaiYoAshCrow Hi,you mean you used barteksc's pdfium as module and add the closePage method in it.Not use xybean's pdfium as module?
@yuquan23459 Yeah, that's what I meant. Sorry I wasn't too clear. You'll need to reference the subproject since the main project is as a whole, the sample and the library project.
@yuquan23459 If you copy the .so file to your own project, you should copy relevant java files without changing their package name.I guess that you have changed the package name of java files.
@HaiYoAshCrow Hi,i have imported the barteksc's pdfium project as module to the AndroidPdfViewer but load failed!The log is: 03-19 10:16:03.279 6939-6939/? E/com.shockwave.pdfium.PdfiumCore: Native libraries failed to load - java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.github.barteksc.sample-2/base.apk"],nativeLibraryDirectories=[/data/app/com.github.barteksc.sample-2/lib/arm, /system/lib, /vendor/lib]]] couldn't find "libmodpng.so" 03-19 10:16:03.344 6939-6959/? E/art: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) 03-19 10:16:03.413 6939-6939/? E/PDFView: load pdf error java.lang.UnsatisfiedLinkError: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method) at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:133) at com.github.barteksc.pdfviewer.source.FileSource.createDocument(FileSource.java:38) at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49) at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)
And the Sample's gradle is: dependencies { compile 'com.android.support:appcompat-v7:25.3.1' provided 'org.androidannotations:androidannotations:4.0.0' compile 'org.androidannotations:androidannotations-api:4.0.0' compile project(':android-pdf-viewer') }, the android-pdf-viewer's gradle is: dependencies { compile project(':PdfiumAndroid') } help,thank you!
@yuquan23459 Once you've included the project as a module, you'll need to run ndk-build as per instructions within pdfiumAndroid. Navigate to your {PDFIUM MODULE PATH}/src/main/jni and run ndk-build from the command line. Note that you're going to have to have NDK tools setup: https://developer.android.com/ndk/guides/index.html.
Have you already solved it,help,thank you
https://developer.android.com/ndk/guides/index.html. this not open
@ToxicBakery Android uses Garbage Collector, when items are removed from cache it doesn't mean that they will be removed from memory immediately
Great knowledge of android. But it crashes after few pages. Please try to found the leak into library. Or at least use LRUCache or WeakReference or something else.
@HaiYoAshCrow @xybean It's cool! My pdf is 400MB big, and when scrolling the pages, the memory rocketed up to 200MB and shut down. But after using your tips, it just goes at best up to 80MB in my Galaxy Note 4. Thank you all!
How can i solve it???
Scroll big pdf, crash!!!
Help....
Hi @Yazon2006 @HaiYoAshCrow @xybean , I have followed the above steps.
i got the following error.
Plugin with id 'com.github.dcendents.android-maven' not found.
Here is android-pdf-viewer build.gradle
apply plugin: 'com.android.library'
ext { bintrayRepo = 'maven' bintrayName = 'android-pdf-viewer'
publishedGroupId = 'com.github.barteksc'
libraryName = 'AndroidPdfViewer'
artifact = 'android-pdf-viewer'
libraryDescription = 'Android view for displaying PDFs rendered with PdfiumAndroid'
siteUrl = 'https://github.com/barteksc/AndroidPdfViewer'
gitUrl = 'https://github.com/barteksc/AndroidPdfViewer.git'
libraryVersion = '3.2.0-beta.1'
developerId = 'barteksc'
developerName = 'Bartosz Schiller'
developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
android { compileSdkVersion 28
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "3.2.0-beta.1"
}
}
dependencies { implementation 'com.android.support:support-compat:28.0.0' //api 'com.github.barteksc:pdfium-android:1.9.0' implementation project(path:':PdfiumAndroid') }
apply from: 'bintray.gradle'
Here is the PdfiumAndroid build.gradle
buildscript { repositories { jcenter() google() maven { url "https://repo.commonsware.com.s3.amazonaws.com" } }
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
}
}
apply plugin: 'com.android.library'
ext { bintrayRepo = 'maven' bintrayName = 'pdfium-android'
publishedGroupId = 'com.github.barteksc'
libraryName = 'PdfiumAndroid'
artifact = 'pdfium-android'
libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap'
siteUrl = 'https://github.com/barteksc/PdfiumAndroid'
gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'
libraryVersion = '1.9.0'
developerId = 'barteksc'
developerName = 'Bartosz Schiller'
developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
android { compileSdkVersion 26
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.9.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets{
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
}
repositories { google() jcenter() }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:support-v4:26.1.0' }
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
Please help. Thanks
Do you want to publish an artifact on maven?
вт, 23 июн. 2020 г., 21:48 kayesn786 notifications@github.com:
Hi @Yazon2006 https://github.com/Yazon2006 @HaiYoAshCrow https://github.com/HaiYoAshCrow @xybean https://github.com/xybean , I have followed the above steps.
- I forked PdfiumAndroid from barteksc and added the closePage() function
- I imported this (PdfiumAndroid) as a module in AndroidPDFViewer and did necessary changes.
- From there, forked the AndroidPDFViewer project by barteksc and did necessary changes.
- Then i imported the above (AndroidPDFViewer) as a module in my project.
i got the following error.
Plugin with id 'com.github.dcendents.android-maven' not found.
Here is android-pdf-viewer build.gradle
apply plugin: 'com.android.library'
ext { bintrayRepo = 'maven' bintrayName = 'android-pdf-viewer'
publishedGroupId = 'com.github.barteksc' libraryName = 'AndroidPdfViewer' artifact = 'android-pdf-viewer'
libraryDescription = 'Android view for displaying PDFs rendered with PdfiumAndroid'
siteUrl = 'https://github.com/barteksc/AndroidPdfViewer' gitUrl = 'https://github.com/barteksc/AndroidPdfViewer.git'
libraryVersion = '3.2.0-beta.1'
developerId = 'barteksc' developerName = 'Bartosz Schiller' developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"]
}
android { compileSdkVersion 28
defaultConfig { minSdkVersion 14 targetSdkVersion 28 versionCode 1 versionName "3.2.0-beta.1" }
}
dependencies { implementation 'com.android.support:support-compat:28.0.0' //api 'com.github.barteksc:pdfium-android:1.9.0' implementation project(path:':PdfiumAndroid') }
apply from: 'bintray.gradle'
Here is the PdfiumAndroid build.gradle
buildscript { repositories { jcenter() google() maven { url "https://repo.commonsware.com.s3.amazonaws.com" } }
dependencies { classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' }
}
apply plugin: 'com.android.library'
ext { bintrayRepo = 'maven' bintrayName = 'pdfium-android'
publishedGroupId = 'com.github.barteksc' libraryName = 'PdfiumAndroid' artifact = 'pdfium-android'
libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap'
siteUrl = 'https://github.com/barteksc/PdfiumAndroid' gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'
libraryVersion = '1.9.0'
developerId = 'barteksc' developerName = 'Bartosz Schiller' developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"]
}
android { compileSdkVersion 26
defaultConfig { minSdkVersion 14 targetSdkVersion 26 versionCode 1 versionName "1.9.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
sourceSets{ main { jni.srcDirs = [] jniLibs.srcDir 'src/main/libs' } }
}
repositories { google() jcenter() }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:support-v4:26.1.0' }
apply from: ' https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' apply from: ' https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
Please help. Thanks
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/barteksc/AndroidPdfViewer/issues/495#issuecomment-648348527, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4IJ6WV6C4XWO3YHG3TJ7LRYD2JVANCNFSM4EKDUUEQ .
No, I am not publishing any artifacts to maven, Do i have to remove those lines of code then?
Yeah, I guess you can just remove this plugin
ср, 24 июн. 2020 г., 08:50 kayesn786 notifications@github.com:
No, I am not publishing any artifacts to maven, Do i have to remove those lines of code then?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/barteksc/AndroidPdfViewer/issues/495#issuecomment-648605143, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4IJ6WXBCXA3CBNUC6RMBTRYGHZLANCNFSM4EKDUUEQ .
Hi, Here is build.glradle of PdfiumAndroid after few modification
buildscript { repositories { jcenter() google() }
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
//classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
apply plugin: 'com.android.library'
/*ext { bintrayRepo = 'maven' bintrayName = 'pdfium-android'
publishedGroupId = 'com.github.barteksc'
libraryName = 'PdfiumAndroid'
artifact = 'pdfium-android'
libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap'
siteUrl = 'https://github.com/barteksc/PdfiumAndroid'
gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git'
libraryVersion = '1.9.0'
developerId = 'barteksc'
developerName = 'Bartosz Schiller'
developerEmail = 'barteksch@boo.pl'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}*/
android { compileSdkVersion 26
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.9.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets{
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
}
repositories { google() jcenter() }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.legacy:legacy-support-v4:1.0.0' }
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' //apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
Now the project gets build without any error, but PDF doesn't show up. It just shows empty fragment.
I have migrated the AndroidPDFViewer-master to Androidx. And i have removed everything from bintray.gradle in android-pdf-viewer
Thanks
@Yazon2006 , Thanks a lot. The issue is resolved. After following all the steps (including NDK building), the memory consumption has drastically reduced to 200Mb from 900Mb.
Awesome! I'm glad for you)
чт, 25 июн. 2020 г., 22:15 kayesn786 notifications@github.com:
@Yazon2006 https://github.com/Yazon2006 , Thanks a lot. The issue is resolved. After following all the steps (including NDK building), the memory consumption has drastically reduced to 200Mb from 900Mb.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/barteksc/AndroidPdfViewer/issues/495#issuecomment-649767575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4IJ6V37QCJLPL3UJVXTH3RYOO4LANCNFSM4EKDUUEQ .
nice work!
谢谢 祝你天天开心哈
谢谢 祝你天天开心哈
I tried the solution not working inside viewpager adapter, how to use this in adapter in which page index is always 0 since each adapter has its own pdfview instance
谢谢 祝你天天开心哈
Did anyone ever solve this? Really need some help to fix this problem
谢谢 祝你天天开心哈
Is anyone able to make a fork of both of these (AndroidPdfViewer and Pdfium) with the required changes?
I'm trying to replace the current version of this repo, that is being used in a Flutter package, and keep getting the problem where it can't find nativeOpenDocument
method.
I've tried everything suggested here and more but must be missing something or doing it wrong.
I am seeing a memory leak when viewing large PDF files in terms of page count. Using an Apollo 17 Flight Plan PDF memory allocation continues to grow as the user scrolls the document and GC does not clear allocations. Inspecting the hprof it appears this is occurring in native code. I inspected the caching mechanism of the library and it appears to work as intended further indicating this is related to native code holding references it shouldn't. I tested this against 2.7.0, 2.8.2, and 3.0.0-beta.4 finding the same result on each version.
Profiler visualization and hprof dump![screenshot from 2018-01-02 13-05-12](https://user-images.githubusercontent.com/1614281/34494273-b6ad8e26-efbd-11e7-93c4-ccea02101383.png)
I created a branch with the mentioned PDF replacing the sample here https://github.com/ToxicBakery/AndroidPdfViewer/tree/feature/memory-leak-large-pdf
Alternately you can get the PDF yourself from the Nasa website here https://www.hq.nasa.gov/alsj/a17/A17_FlightPlan.pdf