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

Only very first image load works (Android) #38

Closed
arivanbastos opened this issue Oct 24, 2016 · 6 comments
Closed

Only very first image load works (Android) #38

arivanbastos opened this issue Oct 24, 2016 · 6 comments

Comments

@arivanbastos
Copy link

arivanbastos commented Oct 24, 2016

I'm using this plugin in a ionic project. I'm calling a function on ng-click event triggered on a element. The function calls "PhotoViewer.show(url);":

<a ng-click="openImage(attachment.path)">
   <img src="{{attachment.thumbnail}}"/>
</a>
$scope.openImage = function(url)
{
     PhotoViewer.show(url);
};

The first time I click the link the image is loaded successfully. The second and subsequent times I got a toast that says "Error loading image.". After that, any other link I click I got the same error message, so I need to restart my app.

I tried change the event from "ng-click" to "on-touch" and add a random GET parameter to my URL to avoid any cache. No success.

I also alerted the url that is sended to "openImage()" function and it is correct.

I'm running:
Cordova CLI 6.3.1
Ionic: 1.3
Ionic cli: 2.1.0
Android 4.4.2

@arivanbastos arivanbastos changed the title Only very first image load works Only very first image load works (Android) Oct 24, 2016
@arivanbastos
Copy link
Author

Getting this stacktrace:

10-24 17:35:01.177 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm-heap: Forcing collection of SoftReferences for 48771088-byte allocation
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass D/dalvikvm: GC_BEFORE_OOM freed 540K, 7% free 53535K/57364K, paused 32ms, total 32ms
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass E/dalvikvm-heap: Out of memory on a 48771088-byte allocation.
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm: "Picasso-/files/common_modules_condoclass_models_FileAttachment/13/13.jpg" prio=5 tid=22 RUNNABLE
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x4255c848 self=0x67bf16a0
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:   | sysTid=385 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1761127896
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:   | state=R schedstat=( 41163792 21130791 17 ) utm=2 stm=1 core=3
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:719)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:695)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:142)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at java.lang.Thread.run(Thread.java:841)
10-24 17:35:01.207 32072-385/com.virtualizesolucoes.condoclass I/dalvikvm:     at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)

@arivanbastos
Copy link
Author

arivanbastos commented Oct 24, 2016

Following http://stackoverflow.com/questions/26938310/picasso-library-out-of-memory and adding ".fit()" (around line 140 PhotoActivity.java) to Picasso loading call fixed the issue:

Before

        Picasso.with(this)
                .load(imageUrl)
                .into(photo, new com.squareup.picasso.Callback() {

After

        Picasso.with(this)
                .load(imageUrl)
                .fit()
                .into(photo, new com.squareup.picasso.Callback() {

@sarriaroman
Copy link
Owner

Yes, the memory issue is because of the size of the image. For some reason I validated that .fit is missing on the current version. I will make the change. Thanks for your help.

@arivanbastos
Copy link
Author

arivanbastos commented Oct 24, 2016

You are welcome. Very nice plugin!

@sarriaroman
Copy link
Owner

Thanks. Please try the version 1.1.8 and let me know if you find anything else.

@arivanbastos
Copy link
Author

The "fit()" patch also solves #39.

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

No branches or pull requests

2 participants