Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.
Apache License 2.0
595 stars 23 forks source link

iOS, macOS, and js support #23

Closed luca992 closed 1 year ago

luca992 commented 1 year ago

This is a draft and not finished yet. But, I have begun adding support for iOS, macOS, and js targets!

luca992 commented 1 year ago

still need rework findFetcherFor and findDecoderFor to work properly on native.... but I got it running on a macosArm64 native application 🎉

cool thing to note. The compose-ui native sample app is way smoother and kamel loads images faster on mac vs jvm

https://user-images.githubusercontent.com/4157455/183836880-b87527f7-e55f-4de4-b264-1cbfb3c3494b.mov

Screen Shot 2022-08-10 at 2 48 25 AM
luca992 commented 1 year ago

Added support for web!

Screen Shot 2022-09-13 at 1 50 31 PMScreen Shot 2022-09-13 at 1 50 38 PM

Basically what needs to be implemented still for the new targets:

PS. I think I can technically remove the full reflection dependency on jvm now. But, I have left it alone for now until I can get some feedback on that @alialbaali

luca992 commented 1 year ago

also you can try it out here:

implementation("io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs1")
alialbaali commented 1 year ago

You've done a fantastic work. I'm very impressed! Thank you for your contribution, and it's really appreciated 🚀.

alialbaali commented 1 year ago

I reviewed the code and it looks good to me. You can go ahead and finish the rest.

cmota commented 1 year ago

hello all!

Let me start by saying: excellent job @luca992! This is no easy task and you're getting there 🙌.

I'm trying to validate this on a side project, but I'm having a crash when loading an image both locally and remotely on the iOS simulator. I'm using Kotlin 1.7.10 and Compose beta02.

Not sure if these logs help though:

4   Unsplash                               0x104f7ae79 konan::abort() + 9
5   Unsplash                               0x104f8afe1 (anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1::operator()() const + 17
6   Unsplash                               0x104f8aecf void (anonymous namespace)::$_0::operator()<(anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1>((anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1) + 47
7   Unsplash                               0x104f8acfd (anonymous namespace)::terminateWithUnhandledException(ObjHeader*) + 45
8   Unsplash                               0x104f8ac9b (anonymous namespace)::processUnhandledException(ObjHeader*) + 91
9   Unsplash                               0x1044d9578 kfun:kotlinx.coroutines#handleCoroutineExceptionImpl(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} + 72
luca992 commented 1 year ago

@cmota Thanks! It's getting there. I haven't tried iOS simulator yet. I'll check it out. I've tested the build on an ios device and it was working however. are you haveing problems with the mac sample too?

cmota commented 1 year ago

I think I've understood the issue, well at least what's causing it! The problem seems to be related with moko-resources.

Did you have any issues when you made your sample?

I've removed its references and now I'm able to load remote images! 🙌

On a side note, I also noticed that I'm not able to load VectorResource.

luca992 commented 1 year ago

@cmota oh looks like I didn't even enable ios targets for the samples module. So don't think I tried running it there.

If I had to guess you're running into this issue on ios https://github.com/icerockdev/moko-resources/issues/362

luca992 commented 1 year ago

On a side note, I also noticed that I'm not able to load VectorResource.

@cmota yeah see my notes on what still needs to be done.

cmota commented 1 year ago

@luca992, yup, I've add the targets manually 🙂.

I'm unable to get a stacktrace as good as that one, though. Is there any trick to it?

luca992 commented 1 year ago

@cmota I added an ios sample... however I can't get the gradle deploy to simulator command to work.

I had to open the generated xcode project and change a setting:

Screen Shot 2022-10-04 at 3 47 59 PM

and to get load from file example working you have to manually add the bundle:

Screen Shot 2022-10-04 at 3 48 44 PM
cmota commented 1 year ago

I managed to get it working without the xcode project, but it would randomly crash.

I'm going to try to see if I can push the project before the end of this week so you could see.

luca992 commented 1 year ago

Huh really. Yeah I would be interested to see how you got it going by command to simulator. And if you have anything different in your setup than what I just pushed. I think native desktop has a random crashing issues too. But that just might be a compose-jb issue. Not sure

gumil commented 1 year ago

Is there a way I can test this on iOS?

luca992 commented 1 year ago

Is there a way I can test this on iOS?

yeah. here https://github.com/alialbaali/Kamel/pull/23#issuecomment-1245765234

luca992 commented 1 year ago

A new kotlin 1.8.20 and compose 1.4.0 build

implementation("io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs2")
luca992 commented 1 year ago

Managed to get svg decoder working on native 🙌

Screenshot 2023-05-06 at 2 59 00 AM
qamarelsafadi commented 1 year ago

A new kotlin 1.8.20 and compose 1.4.0 build

implementation("io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs2")

I am trying to implement it on my project but Gradle keeps tell me that

Could not find io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs2.

any ideas?

luca992 commented 1 year ago

@qamarelsafadi oh oops. I forgot to click release. should be up in a few

luca992 commented 1 year ago

published a release with SvgDecoder for nonJvm:

implementation("io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs3")
luca992 commented 1 year ago

Got ImageVectorDecoder working on native/js and decoding xmls with https://github.com/pdvrieze/xmlutil

Screenshot 2023-05-06 at 11 04 55 PM
luca992 commented 1 year ago

@alialbaali finished everything I wanted to do 🎉. I know you said you gave me permission to merge. But did you want to take a look first?

alialbaali commented 1 year ago

Astonishing work you've done there! Thank you, really appreciated! 🎉🎉🎉

I don't have any issues at all, just a couple of things:

I personally don't mind, so please let me know your thoughts. 🙂

luca992 commented 1 year ago

@alialbaali

  1. Honestly a lot of the names confuse me in general so I just didn't think about it and accepted it for what it was haha. You probably are right.

  2. Really? Publishing has been working fine for me. I might have fixed some bugs though along the way. So maybe it will work as it should now for you as well. I just published again here with the latest:

implementation("io.github.luca992.com.alialbaali.kamel:kamel-image:0.5-darwinandjs4")
  1. I'm down to maintain it. I don't know of any other image loading libraries for compose-multiplatform yet... so this is something I need haha. An organization might work well that way I can tag you in questions if you want to review prs occasionally. One thing you could do if you want to keep publishing under your name would be to setup a release branch which triggers a CI job to publish whenever a PR is merged into it.
alialbaali commented 1 year ago
  1. Makes sense, haha 🥲. Feel free to change the names to whatever suitable maybe in another PR, or discussion. Even the name of the repository if you have something better in mind 😝

  2. Well, that's good to hear!

  3. The thing is, I don't prefer to keep publishing under my name when I'm not really doing any of the work right now. It seems unfair. So, I'm thinking of moving this repo to an organization, buy a domain name, and publish it under that domain. Maybe something like media.kamel:kamel-image:1.0.0. What do you think?

luca992 commented 1 year ago
3. The thing is, I don't prefer to keep publishing under my name when I'm not really doing any of the work right now. It seems unfair. So, I'm thinking of moving this repo to an organization, buy a domain name, and publish it under that domain. Maybe something like `media.kamel:kamel-image:1.0.0`. What do you think?

that works 👍

alialbaali commented 1 year ago

Alright then.

Do you want to stick with the name Kamel? If so, what domain would you like us use?

So far, I found these two:

luca992 commented 1 year ago

I'd probably choose media if it were me. But your choice haha. And I think kamel is a solid name

alialbaali commented 1 year ago

Alright. So, I got the domain, and the repository has been transferred to an organization.

I'm guessing we're going to keep publishing on Maven Central, correct? If so, I think we might need a separate Sonatype Jira account where we can share the credentials? Or is it possible to invite someone to the project?

alialbaali commented 1 year ago

Any thoughts @luca992?

luca992 commented 1 year ago

Alright. So, I got the domain, and the repository has been transferred to an organization.

I'm guessing we're going to keep publishing on Maven Central, correct? If so, I think we might need a separate Sonatype Jira account where we can share the credentials? Or is it possible to invite someone to the project?

I don't think there's really any other viable option besides Maven Central anymore. And if you want to share credentials that's fine. You could make a bitwarden organization if you wanted to do that. But there's no way there's not a way to give multiple accounts permission to release to maven central for an organization.... however I have no idea how that works. Sonatype Jira is so confusing 🙃 maybe you can ask in the same ticket you use to create the new repository?

alialbaali commented 1 year ago

I just need your Sonatype username, so I can let you publish artifacts. @luca992

alialbaali commented 1 year ago

Alright, I messaged you.

iadcialim commented 12 months ago

Thank you guys for this great library! Curious if there is significant change in the usage/documentation?

luca992 commented 11 months ago

Thank you guys for this great library! Curious if there is significant change in the usage/documentation?

There shouldn't have been from this pr. The main README.md should be upto date