moko-resources icon indicating copy to clipboard operation
moko-resources copied to clipboard

Slow loading of string resource at first open of screen

Open Alex009 opened this issue 1 year ago • 1 comments

ios-cocoapods-static-framework.7z.zip

https://github.com/icerockdev/moko-resources/assets/315633/e4c7babb-13b7-47e3-a48c-c1c96c47e408

This is my modification based on your demo, and you can see that there is indeed a delayed response for moko to load.

The first time the app is run, there is a delayed response for moko loading, and it is normal to repeat the operation later.

Originally posted by @syxc in https://github.com/icerockdev/moko-resources/discussions/625#discussioncomment-9364093

Alex009 avatar May 16 '24 05:05 Alex009

https://github.com/icerockdev/moko-resources/discussions/625#discussioncomment-9354106 another demonstration

Alex009 avatar May 16 '24 05:05 Alex009

fun localizedString(stringRes: StringResource): String {
        val bundle = StringDesc.localeType.getLocaleBundle(stringRes.bundle) <-- Here
        val string = bundle.localizedStringForKey(stringRes.resourceId, null, null)
        return if (string == stringRes.resourceId) {
            stringRes.bundle.localizedStringForKey(stringRes.resourceId, null, null)
        } else string
    }

I'm do little research and without bundle we have normal performance.

ExNDY avatar May 19 '24 02:05 ExNDY

fun localizedString(stringRes: StringResource): String {
        val bundle = StringDesc.localeType.getLocaleBundle(stringRes.bundle) <-- Here
        val string = bundle.localizedStringForKey(stringRes.resourceId, null, null)
        return if (string == stringRes.resourceId) {
            stringRes.bundle.localizedStringForKey(stringRes.resourceId, null, null)
        } else string
    }

I'm do little research and without bundle we have normal performance.

ios-cocoapods-static-framework.7z.zip

You can take a look at the demo. You can actually see a slight loading delay in moko loading. This demo is your official example. Based on this, I added two new pages to simulate actual application scenarios. Other places No modifications were made. In fact, I am also very surprised as to why this happens.

syxc avatar May 19 '24 03:05 syxc

@syxc

You can take a look at the demo.

I'm don't say "problem not found", but now i think problem with first replacement bundle content in RAM. Don't know, need research

ExNDY avatar May 19 '24 07:05 ExNDY

@syxc

You can take a look at the demo.

I'm don't say "problem not found", but now i think problem with first replacement bundle content in RAM. Don't know, need research

@ExNDY Understood. Thanks a lot!

syxc avatar May 19 '24 07:05 syxc

fix will be available in 0.24.0-beta-5

Alex009 avatar May 21 '24 05:05 Alex009