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

Too slow Image loading #10

Open
eduardhasanaj opened this issue Oct 23, 2017 · 6 comments
Open

Too slow Image loading #10

eduardhasanaj opened this issue Oct 23, 2017 · 6 comments

Comments

@eduardhasanaj
Copy link

eduardhasanaj commented Oct 23, 2017

 Hi,
I am having a strange bug with a modified version of plugin. After fixing rotation (didnt test before) In a Galaxy tab A t 580 sometimes it loads the image in 8b seconds sometime in 4, but sometimes it loads them fast. In other tablet worst than this one but with android < 7 works fine. I compiled the plugin with sdk target 25 so why can be this issue. I do not know where to start. Please give me a fast response? Could this be an issue in unity side?
Here is code that I use:
#9
Other important thing.
I tried to close area of searching the bug. When we load the image that is landscape there is no code or need to rotate (if i is 180 we need but mostly in my device it is 270 for portrait photos (in problematic device I hadnt chance to test)). So it should work with official version of your plugin (only exif analysis). But the tester report the same time. There is no difference between portrait and landscape. I am definitively gone!

@thedoritos
Copy link
Owner

Hi, @eduardhasanaj2

First of all, you should know where it takes the time.

Open the directory ./unimgpicker_android with AndroidStudio. It's an Android native app project.
You can run it as an Android app in your device.

A small app will launch. It loads image using unimgpicker plugin when the button "Show Picker" is pressed, and reads the picked image with the "Reload Image" button. (FYI, You have to press the reload button because this app can not hook the UnitySendMessage callbacks)

If it still takes the time, I guess the problem is in the plugin.
Then you can place break points like when you develop on Android and investigate it more deeply.

Thank you.

@eduardhasanaj
Copy link
Author

I found this last night. Bitmap.compress is the evil there. it can take from 2 sec to 3 or more.
Definitely we need that task to be performed in gpu rather than cpu. I have something but i do not know if you will like and implement also in ios version (am completely noob here). The idea is to create an OpenGL Texture and pass it to unity.
Let me some time to report back.
Best wishes.

@thedoritos
Copy link
Owner

Thanks for the report. That's a very helpful feedback!

I think depending on OpenGL is not a good idea. Since there is a possibility that a developer choose to use Metal in iOS.

Instead of that, I have a small idea. What about if we use JPEG to the output format.

image.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);

On my device (Nexus 5 with Android 6.0.1), it reduces the compression time in about 1 sec. I could not feel much difference because the original code (to compress it into PNG) did not take much time on the device.

I'm sorry that I don't have Galaxy phones nor Android 7.x devices...
I feel appreciate if you try it.

Thank you.

@eduardhasanaj
Copy link
Author

eduardhasanaj commented Oct 25, 2017

Hmmm I think the total time from when user click to displaying texture in unity should be around 1 sec both. Greater than that I think it is not good. Am i exaggerating?
I think that if we can pass opengl texture to unity we can have a good result. The problem is that I do not know c++. I have done something to create texture but i couldnt find a way to properly pass opengl context to unity. To have a generic code we need the c++ code so we can get the context properly.
I will tryy what you said and perhaps we can get a good result

@eduardhasanaj
Copy link
Author

Hey I tried and I am enjoying amazing results when we use opengl. From 1960 it drop to 16 mills ! WTF!
here is a sample app https://ufile.io/3aed4
now we have just to do another version using opengles20.

@eduardhasanaj
Copy link
Author

Did you test it?

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