Skip to content

Loading PNG on IOS.... #81

@qzzf1w

Description

@qzzf1w

I am using Unity 6.

I have an app that downloads a transparent PNG at runtime and Decodes it as a skbitmap.

It works wonderfully on Android. Fails on IOS. No details just

Error - NDS.ExperienceATP.Services.Navigation.NavigationService.DownloadBitmapAsync[332] - Decode failure for bitmap 'https://stgasa.blob.core.windows.net/srx-sites/SaratogaMonument_CalloutA.png'

I have tried modifying the PNG to make it simpler.
No luck

Thoughts?

    private async UniTask<SKBitmap> DownloadBitmapAsync(string fileName)
    {
        if (string.IsNullOrWhiteSpace(fileName))
            throw new ArgumentException("fileName is null/empty.", nameof(fileName));

        SKBitmap returnValue = null;
        string url = _ConfigURL + fileName;

        using (var request = UnityWebRequest.Get(url))
        {
            request.downloadHandler = new DownloadHandlerBuffer();
            await request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Logger.Error($"Failed downloading bitmap from '{url}' - {request.error}");
                throw new Exception($"Error downloading bitmap from '{url}' - {request.error}");
            }

            byte[] data = request.downloadHandler.data;
            if (data == null || data.Length == 0)
            {
                Logger.Error($"Empty bitmap data from '{url}'.");
                throw new Exception($"Empty bitmap data from '{url}'.");
            }

            try
            {
                returnValue = SKBitmap.Decode(data);
            }
            catch (Exception ex)
            {
                Logger.Error($"Decode failure for bitmap '{url}'", ex);
                throw new Exception($"Decode failure for bitmap '{url}'", ex);
            }

            if (returnValue == null)
            {
                Logger.Error($"Null SKBitmap after decode from '{url}'.");
                throw new Exception($"Null SKBitmap after decode from '{url}'.");
            }
        }

        return returnValue;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions