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

App crashing with cached image on v2.1.0 but not 2.0.0 #244

Open
CodeWithOz opened this issue Feb 7, 2020 · 0 comments
Open

App crashing with cached image on v2.1.0 but not 2.0.0 #244

CodeWithOz opened this issue Feb 7, 2020 · 0 comments

Comments

@CodeWithOz
Copy link

We are seeing crashes in our app (Android and iOS) when we move from version 2.0.0 of this library to version 2.1.0. Our project is a Cordova app which uses the Google Maps plugin. We use custom PNGs that have been cached by imgcache, and then supply the nativeURL (gotten using the file plugin) of the cached file to the .addMarker method of the google maps plugin. We do something like this:

        const originalUrl = 'https://ourdomain.com/path/to/our/image.png';
        const loadImg = new Image();
        loadImg.onload = function () {
            ImgCache.isCached(url, function (path, success) {
                if (!success) {
                    console.log('Trying to Cache profile thumbnail for Map Marker...', url);
                    ImgCache.cacheFile(url, () => {
                        ImgCache.getCachedFile(url, function (path, localPath) {
                            console.log('After successful cache, retrieving cached file for Map Marker...', localPath.nativeURL);
                            map.addMarker({
                                // ... other options
                                icon: {
                                    url: localPath.nativeURL,
                                    size: ...
                                }
                            });
                        });
                    });
                } else {
                    ImgCache.getCachedFile(url, function (path, localPath) {
                        console.log('Retrieving cached file for Map Marker...', localPath.nativeURL);
                        map.addMarker({
                            // ... other options
                            icon: {
                                url: localPath.nativeURL,
                                size: ...
                            }
                        });
                    });
                }
            });
        };
        loadImg.onerror = function () {
            // we use a default img that isn't cached
        };
        loadImg.src = originalUrl;

This is an issue describing the errors we see in the android logcat. Curiously on Android, when we switch from a build containing imgcache 2.0.0 to another containing 2.1.0, the crashes don't happen until a new version of the image is cached; after that the app crashes every time we call map.addMarker with the cached file. And then if we go back to a build containing 2.0.0, the crash continues to happen until we cache a new image. I'd greatly appreciate any insights. Project is private but let me know if there's anything else I may be able to provide. Thanks!

Cordova Android: 8.1.0
Cordova iOS: 5.0.1

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

1 participant