splitio / ios-client

iOS SDK client for Split Software
https://split.io
Other
11 stars 18 forks source link

SDK Ready Not Firing #512

Closed ay8s closed 6 months ago

ay8s commented 7 months ago

I'm seeing some oddness with the latest update to the SDK where the SDk ready event never gets fired. Initially I thought it may have been down to blocking on my network but also seeing the same issue occur on a device over cellular.

Downgrading to the previous version, the event fires correctly. I saw there was a tweak to loading from cache but would still expect the ready event to fire?

Curious if anyone else has seen similar behavior?

hbqdev commented 7 months ago

Hi @ay8s Can you please enable SDK debug logging and share with us the logs for both instances so we can investigate?

Regards

hbqdev commented 7 months ago

hi @ay8s Currently, we have an issue related to the latest version of the SDK, you can revert to the previous version to avoid the issue. A new version with the fix is coming soon.

Regards

hbqdev commented 7 months ago

Hi @ay8s Our SDK version 2.24.6 has been released which has the fix for the SDK ready issue.

Regards,

ay8s commented 7 months ago

Thanks @hbqdev. I did try 2.24.6 but seemed to run into the same issue. Only when reverting to 2.24.4 do I see the expected behavior with my Split checks.

Debug logs below:

["16-04-2024 13:34:58.318", "VERBOSE", "SplitSDK", "[SPTPRF]  TimeChecker started at: 1713299698318"]
["16-04-2024 13:34:58.320", "VERBOSE", "SplitSDK", "Cache URL: file:///......sqlite"]
["16-04-2024 13:34:58.320", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to parse loaded splits 3 ms at 1713299698319"]
["16-04-2024 13:34:58.321", "VERBOSE", "SplitSDK", "[SPTPRF]  Time for ready from cache process 8 ms at 1713299698321"]
["16-04-2024 13:34:58.322", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until feature flags process ended at 1713299698321 3 ms since instanciation start"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "Tracking has been set to true"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "Persisting in memory impressions"]
["16-04-2024 13:34:58.323", "DEBUG", "SplitSDK", "Persistence for impressions has been enabled"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "Persisting in memory events"]
["16-04-2024 13:34:58.323", "DEBUG", "SplitSDK", "Persistence for events has been enabled"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "Persistence has been set to true"]
["16-04-2024 13:34:58.323", "INFO", "SplitSDK", "Split SDK client for key ************* initialized!"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load attributes from cache 0 ms at 1713299698323"]
["16-04-2024 13:34:58.323", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until attributes loaded from cache at 1713299698323 5 ms since instanciation start"]
["16-04-2024 13:34:58.324", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load segments from cache 0 ms at 1713299698323"]
["16-04-2024 13:34:58.324", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until my segments loaded from cache at 1713299698323 5 ms since instanciation start"]
["16-04-2024 13:34:58.325", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load feature flags 1 ms at 1713299698325"]
["16-04-2024 13:34:58.325", "VERBOSE", "SplitSDK", "Using parallel decoding for 191 splits"]
["16-04-2024 13:34:58.325", "VERBOSE", "SplitSDK", "Using all Cores to process splits: 10"]
["16-04-2024 13:34:58.325", "VERBOSE", "SplitSDK", "Task count for parallel decoding: 10"]
["16-04-2024 13:34:58.325", "VERBOSE", "SplitSDK", "Chunck size for parallel decoding: 19"]
["16-04-2024 13:34:58.326", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to parse loaded splits 1 ms at 1713299698326"]
["16-04-2024 13:34:58.327", "VERBOSE", "SplitSDK", "[SPTPRF]  Time for ready from cache process 4 ms at 1713299698327"]
["16-04-2024 13:34:58.328", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until feature flags process ended at 1713299698327 9 ms since instanciation start"]
["16-04-2024 13:34:58.462", "VERBOSE", "SplitSDK", "Pushing impressions to persistent storage"]
["16-04-2024 13:34:58.509", "VERBOSE", "SplitSDK", "[SPTPRF]  Running event on main: SDK_READY_FROM_CACHE at 1713299698508 190 ms since instanciation start"]

Aside from those debug logs. Only the SplitEventSdkReadyFromCache event block gets fired.

hbqdev commented 6 months ago

Hi @ay8s

it Looks like you are holding the local reference of the SDK.

// LOCAL REFERENCE
func test() {
        let sdkKey = "YOUR_SDK_KEY"
        let defaultKey = "test"
        let key: Key = Key(matchingKey: defaultKey)
        let config = SplitClientConfig()

        let factory = DefaultSplitFactoryBuilder()
            .setApiKey(sdkKey)
            .setKey(key)
            .setConfig(config)
            .build()!

        factory.client.on(event: .sdkReadyFromCache) {
            print("READY CACHE")
        }

        factory.client.on(event: .sdkReady) {
            print("READY")
        }
    }

Can you using a global reference for the SDK and see if that fixes the issue? It would be something like this:

// MODULE REFERENCE 
var factory: SplitFactory!
func test() {

        let sdkKey = "YOUR_SDK_KEY"
        let defaultKey = "test"
        let key: Key = Key(matchingKey: defaultKey)
        let config = SplitClientConfig()

        factory = DefaultSplitFactoryBuilder()
            .setApiKey(sdkKey)
            .setKey(key)
            .setConfig(config)
            .build()!

        factory.client.on(event: .sdkReadyFromCache) {
            print("READY CACHE")
        }

        factory.client.on(event: .sdkReady) {
            print("READY")
        }
}

Regards,

ay8s commented 6 months ago

@hbqdev We're still using Objective-C to setup Split and have the SplitClient available via a Singleton.

Split 2.24.4 still continues to work smoothly.

SajjadKharrazi commented 6 months ago

We are using also v2.24.5

class SplitHelper {

    var isSDKReady = false
    var client: SplitClient!

    func build() {
        let config = SplitClientConfig()
        config.logLevel = .verbose
        let builder = DefaultSplitFactoryBuilder()
        let factory = builder.setApiKey(Environment.SPLIT_API_KEY.value)
            .setKey(Key(matchingKey: UIDevice.current.identifierForVendor!.uuidString))
            .setConfig(config)
            .build()

        self.client = factory!.client
        self.client.on(event: SplitEvent.sdkReady) {
            self.isSDKReady = true
        }
        self.client.on(event: SplitEvent.sdkReadyFromCache) {
            self.isSDKReady = true
        }
    }
}

With this logs:

["23-04-2024 11:56:40.772", "VERBOSE", "SplitSDK", "[SPTPRF]  TimeChecker started at: 1713860800771"]
["23-04-2024 11:56:46.354", "VERBOSE", "SplitSDK", "Cache URL: file:///var/mobile/Containers/Data/Application/CD4517D1-4440-42B5-8411-E48E015E4154/Library/Caches/aq8n48se.sqlite"]
["23-04-2024 11:56:46.488", "VERBOSE", "SplitSDK", "Tracking has been set to true"]
["23-04-2024 11:56:46.488", "VERBOSE", "SplitSDK", "Persisting in memory impressions"]
["23-04-2024 11:56:46.488", "DEBUG", "SplitSDK", "Persistence for impressions has been enabled"]
["23-04-2024 11:56:46.488", "VERBOSE", "SplitSDK", "Persisting in memory events"]
["23-04-2024 11:56:46.488", "DEBUG", "SplitSDK", "Persistence for events has been enabled"]
["23-04-2024 11:56:46.488", "VERBOSE", "SplitSDK", "Persistence has been set to true"]
["23-04-2024 11:56:46.489", "INFO", "SplitSDK", "Split SDK client for key 0BDEE5D4-A891-476B-A3CB-CB33F148E2BF initialized!"]
["23-04-2024 11:56:46.490", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load attributes from cache 0 ms at 1713860806489"]
["23-04-2024 11:56:46.490", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until attributes loaded from cache at 1713860806489 5718 ms since instanciation start"]
["23-04-2024 11:56:46.490", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load segments from cache 1 ms at 1713860806490"]
["23-04-2024 11:56:46.490", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until my segments loaded from cache at 1713860806490 5719 ms since instanciation start"]
["23-04-2024 11:56:46.491", "VERBOSE", "SplitSDK", "[SPTPRF]  Time to load feature flags 0 ms at 1713860806490"]
["23-04-2024 11:56:46.491", "VERBOSE", "SplitSDK", "[SPTPRF]  Time for ready from cache process 2 ms at 1713860806491"]
["23-04-2024 11:56:46.491", "VERBOSE", "SplitSDK", "[SPTPRF]  Time until feature flags process ended at 1713860806491 5720 ms since instanciation start"]
["23-04-2024 11:56:46.627", "DEBUG", "SplitSDK", "Split host app become active"]

SDk ready event never gets fired

hbqdev commented 6 months ago

hi @ay8s @SajjadKharrazi

ios SDK 2.24.7 has been released that addressed this issue.

Regards

ay8s commented 6 months ago

Seems to be working smoothly now @hbqdev