Persist Change Bundle Location host setting#57425
Conversation
Change Bundle Location updates PackagerConnectionSettings.debugServerHost, but the setter only updated the in-memory cached host. After the app process restarted, PackagerConnectionSettings read debug_http_host from default SharedPreferences and fell back to the previous value. Persist the selected host to the same debug_http_host preference used by DevSettingsActivity so both entry points share the same storage path.
Abbondanzo
left a comment
There was a problem hiding this comment.
This is actually leftovers from a migration away from persisting the bundle location to disk (#54139). The shared preferences read is only there for legacy reasons, but given that iOS is still writing to disk I think it's fine to reintroduce such a change. Left a few review comments to fix up first
| } | ||
| set(host) { | ||
| if (host.isEmpty()) { | ||
| _cachedOrOverrideHost = null |
There was a problem hiding this comment.
Nit: rather than storing a null string, can you have this remove the string altogether?
There was a problem hiding this comment.
Thanks, updated. I was following what Dev Settings does here, since the EditTextPreference for debug_http_host seems to persist an empty string when cleared. But yeah, removing the key is cleaner for this path since we already treat missing and empty the same when reading it back.
| } | ||
|
|
||
| public open fun resetDebugServerHost() { | ||
| _cachedOrOverrideHost = null |
There was a problem hiding this comment.
The preferences should be cleared here too, but the constructor would have to updated to not call this method and blast this away each time
| preferences.edit().remove(PREFS_DEBUG_SERVER_HOST_KEY).apply() | |
| _cachedOrOverrideHost = null |
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D110990504. |
Summary:
Persist
Change Bundle Locationupdates to the samedebug_http_hostpreference used by the Android Dev Settings screen.Previously,
Change Bundle Locationonly updated the in-memoryPackagerConnectionSettingshost override. After killing and restarting the app process, the host was read again fromSharedPreferences, so the change was lost.Changelog:
[ANDROID] [FIXED] - Persist Change Bundle Location debug server host changes
Test Plan:
Verified with RNTester
debugOptimizedon Android:Change Bundle Location.