capacitor-community / photoviewer

⚑ Capacitor plugin to view table images with fullscreen and sharing capabilities.
MIT License
52 stars 25 forks source link

App crashing when calling PhotoViewer.show after updating to version 3.0 and capacitor 5 #51

Closed connysvensson closed 1 year ago

connysvensson commented 1 year ago

Describe the bug When tapping on a picture in the web app I call Capacitor.Plugins.PhotoViewer.show(opts). This has worked fine all along but when updating to Capacitor 5 (I was on 4 before), raising Android target SDK to version 33 (but keeping minimum to 22) and updating to photo viewer v 3.0 the app is now crashing when making that method call. The stack trace from logcat it shown below. This problem does not happen running the device emulator (on version 33). See my phone info below.

Smartphone (please complete the following information):

Logcat output

2023-08-27 20:18:11.376  4171-4171  Capacitor/Plugin        com.pixits.horc                      V  To native (Capacitor plugin): callbackId: 108875161, pluginId: PhotoViewer, methodName: show
2023-08-27 20:18:11.377  4171-4171  Capacitor               com.pixits.horc                      V  callback: 108875161, pluginId: PhotoViewer, methodName: show, methodData: {"mode":"slider","startFrom":0,"images":[{"url":"https:\/\/elasticbeanstalk-eu-west-1-319513629226.s3-eu-west-1.amazonaws.com\/public\/storage\/images\/23761\/conversions\/IMG_4811-full.jpg","title":""},{"url":"https:\/\/elasticbeanstalk-eu-west-1-319513629226.s3-eu-west-1.amazonaws.com\/public\/storage\/images\/23762\/conversions\/IMG_4812-full.jpg","title":""}],"options":{"backgroundcolor":"black","title":false,"maxzoomscale":4}}
2023-08-27 20:18:11.519  4171-4171  AndroidRuntime          com.pixits.horc                      D  Shutting down VM
2023-08-27 20:18:11.520  4171-4171  AndroidRuntime          com.pixits.horc                      E  FATAL EXCEPTION: main
                                                                                                    Process: com.pixits.horc, PID: 4171
                                                                                                    kotlin.UninitializedPropertyAccessException: lateinit property image has not been initialized
                                                                                                        at com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.getImage(ScreenSlidePageFragment.kt:42)
                                                                                                        at com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.onCreateView(ScreenSlidePageFragment.kt:117)
                                                                                                        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104)
                                                                                                        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524)
                                                                                                        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
                                                                                                        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1901)
                                                                                                        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1819)
                                                                                                        at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1731)
                                                                                                        at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
                                                                                                        at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:353)
                                                                                                        at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:284)
                                                                                                        at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:72)
                                                                                                        at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7867)
                                                                                                        at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:893)
                                                                                                        at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
                                                                                                        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8902)
                                                                                                        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8860)
                                                                                                        at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8848)
                                                                                                        at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1645)
                                                                                                        at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
                                                                                                        at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
                                                                                                        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4309)
                                                                                                        at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4012)
                                                                                                        at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4578)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:533)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
                                                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
                                                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1248)
                                                                                                        at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:934)
                                                                                                        at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:954)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
                                                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
                                                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
                                                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
                                                                                                        at android.view.View.layout(View.java:23750)
2023-08-27 20:18:11.521  4171-4171  AndroidRuntime          com.pixits.horc                      E      at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
                                                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
                                                                                                        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
                                                                                                        at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
                                                                                                        at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
                                                                                                        at com.android.internal.policy.DecorView.onLayout(DecorView.java:1099)
                                                                                                        at android.view.View.layout(View.java:23750)
                                                                                                        at android.view.ViewGroup.layout(ViewGroup.java:7277)
                                                                                                        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3709)
                                                                                                        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3161)
                                                                                                        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2222)
                                                                                                        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9123)
                                                                                                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:999)
                                                                                                        at android.view.Choreographer.doCallbacks(Choreographer.java:797)
                                                                                                        at android.view.Choreographer.doFrame(Choreographer.java:732)
                                                                                                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:984)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:883)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                        at android.os.Looper.loop(Looper.java:237)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8167)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2023-08-27 20:18:11.526  4171-4171  com.pixits.hor          com.pixits.horc                      W  Attempt to remove non-JNI local reference, dumping thread
2023-08-27 20:18:11.543  4171-4171  Process                 com.pixits.horc                      I  Sending signal. PID: 4171 SIG: 9
rapelt commented 1 year ago

https://github.com/capacitor-community/photoviewer/pull/46/files

connysvensson commented 1 year ago

I pulled down the latest 3.0.1 and did a clean build but unfortunately did not fix my problem. Exactly the same error log

beliven-francesco-delgiudice commented 1 year ago

I'm having a similar problem but my app crashes also when run on the emulator. Actually it crashes also with the Media plugin

jepiqueau commented 1 year ago

@connysvensson @beliven-francesco-delgiudice Cannot reproduce the issue look at ionic7-angular-photoviewer-app it uses Capacitor5 and the latest release of @capacitor-community/photoviewer. Caan you test it on your side and tell me if it works and then compare with your app. Could be an authorization issue with your amazon account where the images are stored

beliven-francesco-delgiudice commented 1 year ago

I don't have my images on aws and I have full permissions. Anyway I'm not using this library anymore but thanks for the feedback

jepiqueau commented 1 year ago

@beliven-francesco-delgiudice would be interesting to understand the issue so if you can share a repro of your app it would be nice which other library are you using

beliven-francesco-delgiudice commented 1 year ago

I needed this library to zoom on pictures but capacitor 7 with swiper offer this functionality without having to install another library. I am still encountering crashes on real devices when using the [Media plugin] (https://github.com/capacitor-community/media) and I'm still yet to discover why

jepiqueau commented 1 year ago

@connysvensson Can you share your code?

ivanov84 commented 1 year ago

@jepiqueau, same error on android (tested on API 24 and on API 33 - black screen) after migrating to Capacitor 5... Photoviewer 3.0.3... Is it possible to fix somehow version 2 to adopt to Capacitor 5? I very need a working app... I can fix plugin myself, but I need to know what exactly. On ios black screen....

My code:

const capImage = 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg';
const capImage: Image = {url: url, title: '_'};
const viewerOptions: ViewerOptions = {share: true, title: false};
const capOptions: capShowOptions = {images: [capImage], mode: 'one', startFrom: 0, options: viewerOptions};
PhotoViewer.show(capOptions)

P.S.: path gave me plugin "@capacitor/filesystem@5.1.4"

ivanov84 commented 1 year ago

@jepiqueau, also if I try to open an array with images I see a crash:

FATAL EXCEPTION: main
    Process: com.olympapp.lovewidget.android, PID: 22228
    kotlin.UninitializedPropertyAccessException: lateinit property image has not been initialized
    at com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.getImage(ScreenSlidePageFragment.kt:43)
    at com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.onCreateView(ScreenSlidePageFragment.kt:117)
    at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
    at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1751)
    at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
    at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:343)
    at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:274)
    at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:74)
    at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:8377)
    at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:954)
    at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:9430)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9388)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9375)
    at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1676)
    at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622)
    at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687)
    at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4645)
    at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4348)
    at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4919)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:535)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1248)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:934)
    at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:954)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
02:53:05.219  E     at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at com.android.internal.policy.DecorView.onLayout(DecorView.java:910)
    at android.view.View.layout(View.java:18874)
    at android.view.ViewGroup.layout(ViewGroup.java:5954)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2697)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2413)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1550)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7190)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:959)
    at android.view.Choreographer.doCallbacks(Choreographer.java:734)
    at android.view.Choreographer.doFrame(Choreographer.java:670)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:945)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
jepiqueau commented 1 year ago

@ivanov84 Can you share your code on github so i could have a look on what is going on

ivanov84 commented 1 year ago

@jepiqueau I could create new project, but I think it's not a bug in code - it's problem with performance. When there is no memory - then appears that crash. I think that when initizilization procced should be pasted something like "await" before load images to screen.

jepiqueau commented 1 year ago

@ivanov84 How many images are you loading and what are the size of them? i will have a look. Is it a direct call to the slider or it is through the gallery then select the image and use the slider

ivanov84 commented 1 year ago

@jepiqueau 5 files, each ~155 kB, on 4th plugin version it was all right.

Code:

const capImages = ['file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg', 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg', 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg', 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg', 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg'];
const viewerOptions: ViewerOptions = {share: true, title: false};
const capOptions: capShowOptions = {images: capImages, mode: 'slider', startFrom: targetIndex, options: viewerOptions};
await PhotoViewer.show(capOptions);
jepiqueau commented 1 year ago

@ivanov84 Well there are quite small so why do you suspect the "no memory" ?

jepiqueau commented 1 year ago

@ivanov84 can you try ionic7-angular-photoviewer-app with your capImages and tell me if it works

ivanov84 commented 1 year ago

@jepiqueau because that error happens only on my emulator when my pc is very busy or on android 7 after click on array with photo

jepiqueau commented 1 year ago

@ivanov84 there is nothing i can do more either you send your app or you make the test with the application with the given link and tell me it it works or not.

ivanov84 commented 1 year ago

@jepiqueau, ok. That my app: [deleted]

To test: open chats, load default chat -> open chat with funny images and click on it.

jepiqueau commented 1 year ago

@ivanov84 i load the app but i could not see how to follow your instruction. I do not want to loose my time on this. Try to debug your app and see what is going on. When you find the reason for the bug to happen ask me again by clearly explaining everything

ivanov84 commented 1 year ago

@jepiqueau as I said plugin tried to load images before plugin initialization is finished. It happened on devices that have low memory and if app uses a lot of memeory. Need to edit kotlin code in plugin and fix it. At 43 line.

com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.getImage(ScreenSlidePageFragment.kt:43)

I really don't know whats logic there. If I developed a plugin then I could fix it. But I didn't develope this plugin.

jepiqueau commented 1 year ago

@ivanov84 i saw your image are save in the. cache of the device may be your cache is full . As i said try to run my app in a low memory device and see if it is failing or not if yes report to me. i do not know why you store them in the cache directory, you could have store them in the files or documents folders which let your cash free for the android system

jepiqueau commented 1 year ago

@ivanov84 in fact the path 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg' is not supported. It works for url like:

      this.imageList.push({url: 'file:///sdcard/DCIM/IMG_0001.JPG', title: 'Image1'});
      this.imageList.push({url: 'file:///sdcard/DCIM/IMG_0002.JPG', title: 'Image2'});
      this.imageList.push({url: 'file:///sdcard/Pictures/IMG_0003.JPG', title: 'Image3'});
      this.imageList.push({url: 'http://localhost/_capacitor_file_/storage/emulated/0/Pictures/JPEG_20221001_113835_7582877022250987909.jpg', title: 'Imagelocalhost'});
      this.imageList.push({url: 'capacitor://localhost/_capacitor_file_/storage/emulated/0/Pictures/JPEG_20221001_102529_2463134056977343449.jpg', title: 'Imagelocalhost'});

so your problem is nothing to do with the move to Capacitor 5 as the class ImageToBeLoaded did not changed now i test it and if you define

 this.imageList.push({url: 'capacitor://localhost/_capacitor_file_/data/data/com.jeep.app.ionic7.angular.photoviewer/cache/CACHED-IMG/test_image.jpg', title: 'ImageFromLibrary'});

it should work.

jepiqueau commented 1 year ago

@ivanov84 replace "com.jeep.app.ionic7.angular.photoviewer" with your app_id

ivanov84 commented 1 year ago

@jepiqueau on version 4 of this plugin that urls worked well. The main question - how to fix crash bug. When I used 4 version no crashes was with this plugin.

ivanov84 commented 1 year ago

@jepiqueau, P.S.: a crash happens only if I load an array with images (mode: 'slider'), when I load 1 image (mode: 'one') - all works well.

jepiqueau commented 1 year ago

@ivanov84 did you try the url i told you to use instead. You must not use the cache to store your image as i use the cache when loading the images from http so may be the cache is full. You should listen the guy who develop the app. I remember to you that you are using an open- source plugin which i develop on my free time. I cannot reproduce your issue. And it seems that your are the only one to get it. So better to look at your code and align it to my recommandation.

ivanov84 commented 1 year ago

@jepiqueau just look at issue author, it's not me.

ivanov84 commented 1 year ago

@jepiqueau, especially for you demonstration video with stored images into documents not into a cache - result same:

[deleted]

Just run emulator on API 24 to test.

P.S.: if you learn Kotlin then it's better not to participate in Capacitor team. Because your experiments decrease a reputution of Capacitor. You implemented logic that you don't understand, please check this issue: https://stackoverflow.com/questions/57182703/uninitializedpropertyaccessexception-lateinit-property-has-not-been-initialized

ivanov84 commented 1 year ago

at com.getcapacitor.community.media.photoviewer.fragments.ScreenSlidePageFragment.onCreateView(ScreenSlidePageFragment.kt:117):

tvGalleryTitle.text = image.title ?: ""

Throw a crash

image - it's a lateinit property. In method onCreateView it has not initialized when calls. Bad architecture.

ivanov84 commented 1 year ago

@jepiqueau, okey, if I change this:

lateinit var image: Image

to this:

var image: Image? = null

and a little code with adding question mark to end for "image" variable, then there is no crash, but there is a black screen with close button, means that "image" is null.

jepiqueau commented 1 year ago

@ivanov84 This will be fixed in the next release, i forgot to put the code for API lower than 33

jepiqueau commented 1 year ago

@ivanov84 in mean time can you test the modification in ScreenSlidePageFragment.kt

        if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            image = requireArguments().getParcelable(ARG_IMAGE,Image::class.java)!!
        } else {
          image = requireArguments().getParcelable<Image>(ARG_IMAGE)!!
        }

and tell me if it works

connysvensson commented 1 year ago

@ivanov84 in mean time can you test the modification in ScreenSlidePageFragment.kt

        if (SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            image = requireArguments().getParcelable(ARG_IMAGE,Image::class.java)!!
        } else {
          image = requireArguments().getParcelable<Image>(ARG_IMAGE)!!
        }

and tell me if it works

I can tell you this fixed my problem! It worked with single images before but not slider. Now testing this code above it all works great without crashing! This definitely fixed my problem, as I stated the problem happened below SDK 33.

jepiqueau commented 1 year ago

@connysvensson thanks for testing and give your feedback, sorry i did not think that it could have come from the API level so i test it on API32 and it failed so i go back to the code and see that i removed the code for API lower than 33. I am sorry for the disagreement. this will be fixed in next release

ivanov84 commented 1 year ago

@jepiqueau, thank you. Everything worked. Sorry for the emotions, Google is pushing with its demands. And if I released the app like this, then there would be negative reviews with 1 star instead of 5.

jepiqueau commented 1 year ago

@ivanov84 i also modify the class ImageToBeLoaded to make sure that the path 'file:///data/user/0/com.xxx.xxx.android/cache/CACHED-IMG/73256117-d2d8-4d34-af22-d45c8b6dcefb.jpg' is well handle.

jepiqueau commented 1 year ago

@connysvensson @ivanov84 release 3.0.4 has been released

connysvensson commented 1 year ago

Awesome, updated and everything works now. Just uploading new version to Google Play...

ivanov84 commented 1 year ago

@jepiqueau, thank you πŸ™ All works as before πŸ™πŸ™πŸ™