NativeScript / NativeScript

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
https://nativescript.org
MIT License
24.29k stars 1.64k forks source link

Image disposal removes ImageSource content event when directly passed to the component. #10625

Open boutier opened 2 months ago

boutier commented 2 months ago

Issue Description

On iOS, I have an ImageSource that I want to pass to some Image components:

<Image *ngIf="cond" [src]="myImageSource"></Image>
<Image *ngIf="otherCond" [src]="myImageSource"></Image>

But when Image is disposed, it clears the content of the provided ImageSource (this.imageSource.ios = null;), which makes it not reusable!

https://github.com/NativeScript/NativeScript/blob/050601232ac4f424e9d3ba6b711f3ada4afe253b/packages/core/ui/image/index.ios.ts#L29-L41

Note that when src is an ImageSource, the _createImageSourceFromSrc function does not create but just use the provided ImageSource

https://github.com/NativeScript/NativeScript/blob/050601232ac4f424e9d3ba6b711f3ada4afe253b/packages/core/ui/image/image-common.ts#L124-L127

Reproduction

No response

Relevant log output (if applicable)

No response

Environment

No response

Please accept these terms

CatchABus commented 8 hours ago

Interesting. Does android behave as expected?