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

client_id changes across releases #1239

Closed
Tracked by #1236
bryanoltman opened this issue Sep 8, 2023 · 10 comments · Fixed by shorebirdtech/engine#47
Closed
Tracked by #1236

client_id changes across releases #1239

bryanoltman opened this issue Sep 8, 2023 · 10 comments · Fixed by shorebirdtech/engine#47
Assignees
Labels
bug Something isn't working

Comments

@bryanoltman
Copy link
Contributor

bryanoltman commented Sep 8, 2023

We thought we had code to keep these consistent, but it's not working in testing.

@bryanoltman bryanoltman mentioned this issue Sep 8, 2023
46 tasks
@bryanoltman bryanoltman added this to 1.0 Sep 8, 2023
@bryanoltman bryanoltman moved this to Todo in 1.0 Sep 8, 2023
@bryanoltman bryanoltman added the bug Something isn't working label Sep 8, 2023
@bryanoltman bryanoltman self-assigned this Sep 11, 2023
@bryanoltman bryanoltman moved this from Todo to Done in 1.0 Sep 11, 2023
@bryanoltman bryanoltman moved this from Done to In Progress in 1.0 Sep 11, 2023
@bryanoltman
Copy link
Contributor Author

This may simply be a development build issue. Just verified this is not an issue on iOS, waiting for play store approval to verify on Android.

@eseidel
Copy link
Contributor

eseidel commented Sep 11, 2023

Seems reasonable to me. Feel free to close.

@eseidel
Copy link
Contributor

eseidel commented Sep 11, 2023

Closing based on the belief this is fixed.

@eseidel eseidel closed this as completed Sep 11, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in 1.0 Sep 11, 2023
@bryanoltman bryanoltman reopened this Sep 11, 2023
@bryanoltman bryanoltman moved this from Done to Todo in 1.0 Sep 11, 2023
@eseidel
Copy link
Contributor

eseidel commented Sep 11, 2023

Supposedly Android does not clear the cache path on update:
https://stackoverflow.com/questions/51148717/does-android-clean-app-cache-on-update

We get our cache path passed down to us from Java:
https://github.com/shorebirdtech/engine/blob/655974aed33b608d1075cffae0fcaf06772d90d8/shell/platform/android/flutter_main.cc#L126

Which is passed into init here:
https://github.com/shorebirdtech/engine/blob/655974aed33b608d1075cffae0fcaf06772d90d8/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java#L200

Which comes from:
https://github.com/shorebirdtech/engine/blob/655974aed33b608d1075cffae0fcaf06772d90d8/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java#L328

Which is the result of this task:
https://github.com/shorebirdtech/engine/blob/655974aed33b608d1075cffae0fcaf06772d90d8/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java#L207

Which appears to come from this call:
https://github.com/shorebirdtech/engine/blob/655974aed33b608d1075cffae0fcaf06772d90d8/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java#L200

So this is where the actual path resolution is:
https://github.com/shorebirdtech/engine/blob/shorebird/dev/shell/platform/android/io/flutter/util/PathUtils.java#L33

Which calls this:
https://developer.android.com/reference/android/content/Context#getCodeCacheDir()

I suspect that's not the directory we want? I suspect the codeCache may be cleared on release? Then again maybe we should store the code there, just not other things like the state.json.

It's also possible that Flutter itself is detecting the release change and nuking the code dir?

@eseidel
Copy link
Contributor

eseidel commented Sep 11, 2023

See also flutter/flutter#14704.

I think the net of this is that we need to be a bit smarter about how we store things on Android?

@eseidel
Copy link
Contributor

eseidel commented Sep 11, 2023

My guess is we should consider just pulling clientId out of state.json for now? Or just ignore this for now. I doubt this blocks our 1.0?

@bryanoltman
Copy link
Contributor Author

It looks like the directory structure is being preserved but that state.json is being deleted. Logs from a custom updater build, where code_cache_dir is /data/user/0/com.example.android_clientid/code_cache and updater_cache_dir is /data/user/0/com.example.android_clientid/code_cache/shorebird_updater

09-12 11:30:02.782 10599 10599 I flutter : updater::cache: code_cache_dir contents: [Ok(DirEntry("/data/user/0/com.example.android_clientid/code_cache/shorebird_updater"))]
09-12 11:30:02.782 10599 10599 I flutter : updater::cache: updater_cache_dir exists? true
09-12 11:30:02.782 10599 10599 I flutter : updater::cache: updater_cache_dir contents: []

@bryanoltman
Copy link
Contributor Author

Code cache dir is the wrong place to put this:

The system will delete any files stored in this location both when your specific application is upgraded, and when the entire platform is upgraded.

(from https://developer.android.com/reference/android/content/Context#getCodeCacheDir())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
2 participants