{"action":"created","issue":{"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/948","repository_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading","labels_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/948/labels{/name}","comments_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/948/comments","events_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/948/events","html_url":"https://github.com/luberda-molinet/FFImageLoading/issues/948","id":298326762,"number":948,"title":"LoadingPlaceholder not appearing until ImageSource.FromStream() finished loading","user":{"login":"ParticularEric","id":9088071,"avatar_url":"https://avatars3.githubusercontent.com/u/9088071?v=4","gravatar_id":"","url":"https://api.github.com/users/ParticularEric","html_url":"https://github.com/ParticularEric","followers_url":"https://api.github.com/users/ParticularEric/followers","following_url":"https://api.github.com/users/ParticularEric/following{/other_user}","gists_url":"https://api.github.com/users/ParticularEric/gists{/gist_id}","starred_url":"https://api.github.com/users/ParticularEric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ParticularEric/subscriptions","organizations_url":"https://api.github.com/users/ParticularEric/orgs","repos_url":"https://api.github.com/users/ParticularEric/repos","events_url":"https://api.github.com/users/ParticularEric/events{/privacy}","received_events_url":"https://api.github.com/users/ParticularEric/received_events","type":"User","site_admin":false},"labels":[{"id":308672687,"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/labels/Xamarin.Forms","name":"Xamarin.Forms","color":"207de5","default":false},{"id":291121060,"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/labels/more%20info%20needed","name":"more info needed","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-02-19T16:01:55Z","updated_at":"2018-03-27T14:29:17Z","closed_at":"2018-03-27T14:29:17Z","author_association":"NONE","body":"### Description\r\n\r\nHi, I am using FFImageLoading in my Xamarin.Forms project but I don´t get  the behaviour I want. I have a list of objects containing the URL for a method to get an image via ImageSource.FromStream for each object. \r\nIn my current example I have 15 of these objects and it takes around 10 seconds to load the pictures. I use a LoadingPlaceholder for that time, but it does not work as expected: Every image is blank for around 9.5 seconds, then I see the loading placeholder for 0.5 seconds and then my downloaded picture. Obviously I would like the placeholder to show the whole time until the download is finished.\r\n\r\nI guess its my code, could you give me a hint what I have to change to see the placeholder instantly?\r\n\r\n### Basic Information\r\n\r\n- Version with issue: 2.3.4\r\n- Last known good version: \r\n- Platform: Xamarin.Forms / testing on Android\r\n\r\n### Screenshots\r\nHere is a gif of the behaviour:\r\n![recipeloading](https://user-images.githubusercontent.com/9088071/36386549-636f93f4-1596-11e8-9e1b-737be4ca7f7d.gif)\r\n\r\n\r\n### Reproduction Link / Code\r\nThis is the basic code example I am experiencing the problem. RecipeGuessResult just has the url and a name in it.\r\n\r\n```C#\r\npublic class MyClass : ContentPage\r\n    {\r\n        List<RecipeGuessResult> recipeResults;\r\n        public MyClass(List<RecipeGuessResult> recipeResults)\r\n        {\r\n            this.recipeResults = recipeResults;\r\n\r\n            ScrollView scrollPage = new ScrollView();\r\n            StackLayout page = new StackLayout();\r\n            page.Spacing = 0;\r\n            Padding = 0;\r\n            BackgroundColor = Color.White;\r\n            scrollPage.Content = page;\r\n            foreach (RecipeGuessResult recipe in recipeResults)\r\n            {\r\n                RecipeResultStack resultStack = new RecipeResultStack(recipe);\r\n                page.Children.Add(resultStack);\r\n            }\r\n            Content = scrollPage;\r\n        }\r\n\r\n        public class RecipeResultStack : StackLayout\r\n        {\r\n            public RecipeResultStack(RecipeGuessResult recipe)\r\n            {\r\n                CachedImage recipeImage = new CachedImage();\r\n                recipeImage.HeightRequest = 200;\r\n                recipeImage.WidthRequest = 320;\r\n                recipeImage.LoadingPlaceholder = \"recipe_loading\";\r\n                recipeImage.ErrorPlaceholder = \"recipe_error\";\r\n                recipeImage.Aspect = Aspect.AspectFill;\r\n                if (!String.IsNullOrEmpty(recipe.imageUrl))\r\n                {\r\n                    recipeImage.Source = ImageSource.FromStream(() => new MemoryStream(App.MyMethod(recipe.imageUrl)));\r\n                }\r\n                else\r\n                    recipeImage.Source = \"recipe_default\";\r\n\r\n                Children.Add(recipeImage);\r\n                Label nameLabel = new Label();\r\n                nameLabel.Text = recipe.name;\r\n                Children.Add(nameLabel);\r\n            }\r\n        }\r\n\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/comments/376546190","html_url":"https://github.com/luberda-molinet/FFImageLoading/issues/948#issuecomment-376546190","issue_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/948","id":376546190,"user":{"login":"ParticularEric","id":9088071,"avatar_url":"https://avatars3.githubusercontent.com/u/9088071?v=4","gravatar_id":"","url":"https://api.github.com/users/ParticularEric","html_url":"https://github.com/ParticularEric","followers_url":"https://api.github.com/users/ParticularEric/followers","following_url":"https://api.github.com/users/ParticularEric/following{/other_user}","gists_url":"https://api.github.com/users/ParticularEric/gists{/gist_id}","starred_url":"https://api.github.com/users/ParticularEric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ParticularEric/subscriptions","organizations_url":"https://api.github.com/users/ParticularEric/orgs","repos_url":"https://api.github.com/users/ParticularEric/repos","events_url":"https://api.github.com/users/ParticularEric/events{/privacy}","received_events_url":"https://api.github.com/users/ParticularEric/received_events","type":"User","site_admin":false},"created_at":"2018-03-27T14:29:17Z","updated_at":"2018-03-27T14:29:17Z","author_association":"NONE","body":"Hey, I just want to say that I was able to fix it. It has/had nothing to do with your plugin, rather some weird Xamarin stuff. However, the solution:\r\n\r\nnew method:\r\n```\r\nstatic List<KeyValuePair<string, CachedImage>> loadList = new List<KeyValuePair<string, CachedImage>>();\r\nprivate static void LoadAndDisplayRecipeImages()\r\n{\r\n        foreach (KeyValuePair<string, CachedImage> x in loadList)\r\n\t{\r\n\t\tbyte[] b =MyApp.GetRecipeImage(x.Key);\r\n\t\tDevice.BeginInvokeOnMainThread(() =>\r\n\t\t{\r\n\t\t\tImageSource source = ImageSource.FromStream(() => new MemoryStream(b));\r\n\t\t\tx.Value.Source = source;\r\n\t\t});\r\n\t}\r\n}\r\n```\r\nRecipeResultStack:\r\n`loadList.Add(new KeyValuePair<string, CachedImage>(recipeResult.imageUrl, recipeImage));`\r\n\r\nAnd at the very end of the page constructor:\r\n```\r\n//Load recipe images:\r\nif (loadList.Any())\r\n{\r\n\tTask.Run(() =>\r\n\t{\r\n\t\tLoadAndDisplayRecipeImages();\r\n\t});\r\n}\r\n```\r\n\r\nIt now works exactly as expected, the page loads fast, shows the placeholder and one after the other turns into the real image."}}
{"actor":{"display_login":"ParticularEric"}}