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

Image disappears after app resigns active #6

Open
lukemorse opened this issue Jun 30, 2020 · 3 comments
Open

Image disappears after app resigns active #6

lukemorse opened this issue Jun 30, 2020 · 3 comments

Comments

@lukemorse
Copy link

Hello,

First of all, thanks for the great code! I'm experiencing an issue when the app enters background, and then becomes active again. The image goes away, replaced by the placeholder, and the image never reloads. I get this error in the console: 2020-06-30 15:53:20.517988-0500 AsyncImage[23959:3569320] [] nw_read_request_report [C1] Receive failed with error "Software caused connection abort"

Anybody find a way to fix this?

@V8tr
Copy link
Owner

V8tr commented Sep 24, 2020

Hi @lukemorse ! If I correctly understood and reproduced the issue, the problem was that onDisappear() was called when view entered background, but onAppear() was never called. Could you please check again with the current version of the project? It now uses StateObject instead of ObservedObject, which, from my experience, fixed the problem.

@nthState
Copy link

nthState commented Jan 15, 2021

@lukemorse This may not be the best way and it may expose other issues, but if your constructor looks like this:

init(url: URL) {
    self.url = url
  }

You can change it to this and images now show when coming back in iOS13

init(url: URL) {
    self.url = url
    
    load()
  }

@nrj
Copy link

nrj commented Aug 23, 2021

I'm experiencing this issue too, however not when backgrounding. It seems that onAppear is not called when the bound image url changes either.

In my case when my view loads, an AsyncImage is rendered with a binding to a selectedImageURL property. The image init is called first and then onAppear is called triggering the image load, which loads the current selected image.

However when I pop up an image picker sheet and allow the user to change the selected image, which changes the selectedImageURL binding, the view is rebuilt and the init is called again, but the onAppear is not called again. This means the old selected image stays visible.

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

3 participants