Skip to content

IAF | Persisting the webview after close #270

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

Merged
merged 12 commits into from
May 29, 2025

Conversation

evan-masseau
Copy link
Contributor

@evan-masseau evan-masseau commented May 23, 2025

Description

Finally updates the WebView to stay in memory after closing, and adds proper hooks to reinitialize on company ID change and lifecycle timeout.

Due Diligence

  • I have tested this on an emulator and/or a physical device.
  • I have added sufficient unit/integration tests of my changes.
  • I have adjusted or added new test cases to team test docs, if applicable.
  • I am confident these changes are compatible with all Android versions the SDK currently supports.

Release/Versioning Considerations

  • Patch Contains internal changes or backwards-compatible bug fixes.
  • Minor Contains changes to the public API.
  • Major Contains breaking changes.
  • Contains readme or migration guide changes.
    • If so, please merge to a feature branch so documentation updates only go live upon official release.
  • This is planned work for an upcoming release.
    • If no, author or reviewer should account for this in a release plan, or describe why not below.

Changelog / Code Overview

Primary stuff:

  • Added unregister API method, and an internal reinitialize for resetting the webview
  • Added company ID observer to trigger webview close+reinit on company change
  • Adjusted the existing lifecycle listener implementation to use reinit method
  • Fixed threading issues when destroying the webview from a non-ui thread

Secondary stuff supporting the above

  • Made "api_key" keyword public from analytics package so it can be reused
  • Moved moved thread handler helpers from API client into core to be a general purpose util
  • And added a runOnUiThread method to replace dependence on the nullable currentActivity

Test Plan

TODO - will compile in #265 so we can test against the fully merged branch

Related Issues/Tickets

Partially blocked by a bug that is fixed in #271

CHNL-19953

@evan-masseau evan-masseau changed the base branch from master to ecm/iaf-observers May 23, 2025 19:26
@evan-masseau evan-masseau marked this pull request as ready for review May 27, 2025 20:58
@evan-masseau evan-masseau requested a review from a team as a code owner May 27, 2025 20:58
@evan-masseau evan-masseau requested a review from dan-peluso May 27, 2025 20:58
@evan-masseau evan-masseau force-pushed the ecm/iaf-persist-webview branch from a001b43 to ea1de3f Compare May 29, 2025 13:37
@evan-masseau evan-masseau merged commit 1236da0 into ecm/iaf-observers May 29, 2025
7 checks passed
@evan-masseau evan-masseau deleted the ecm/iaf-persist-webview branch May 29, 2025 17:15
evan-masseau added a commit that referenced this pull request May 30, 2025
…rvers (#265)

* Added a bridge message so that webview knows when the local JS asset is present

* Added a little observer framework for webview to start/stop observers when webview is able to receive

* IAF | Lifecycle observers to support foreground/backgrounding tracking (#267)

* Implements lifecycle observers to support foreground/backgrounding. Added a foregrounding event to lifecycle monitor

* IAF | Profile observers (#266)

* Adjusted several class/interface names in the bridge subpackage (#268)

* State management/observer improvements (#271)

* Fixes to state observers:
- We can't re-instantiate State every time initialize is called: now that another module relies on State observers, we must be able to keep those observers in memory. Luckily, there's no ill effect of treating State as a singleton (in fact, we used to have it as an Object instead of Class)
- We need state observers to be able to start/stop in reaction to a state change, so our prior concurrency solution is insufficient because that will encounter a concurrent mutation error. CopyOnWrite is the easy solution (converting to Rx is the better long term, but more complex?)

* Convert the callback type for state observers from a two-arg key/value thing, which was confusing, to a strongly typed data class, left the old one in so this isn't a breaking change, even if it is just core

* IAF | Persisting the webview after close (#270)

* Move thread util to core package so it can be shared

* Keep the webview in memory when detaching (i.e. after closing)

* Add company ID observer to re-initialize the webview when company changes

* Add unregister and reinitialize forms API methods
@evan-masseau evan-masseau mentioned this pull request May 30, 2025
9 tasks
evan-masseau added a commit that referenced this pull request May 30, 2025
…rvers (#265)

* Added a bridge message so that webview knows when the local JS asset is present

* Added a little observer framework for webview to start/stop observers when webview is able to receive

* IAF | Lifecycle observers to support foreground/backgrounding tracking (#267)

* Implements lifecycle observers to support foreground/backgrounding. Added a foregrounding event to lifecycle monitor

* IAF | Profile observers (#266)

* Adjusted several class/interface names in the bridge subpackage (#268)

* State management/observer improvements (#271)

* Fixes to state observers:
- We can't re-instantiate State every time initialize is called: now that another module relies on State observers, we must be able to keep those observers in memory. Luckily, there's no ill effect of treating State as a singleton (in fact, we used to have it as an Object instead of Class)
- We need state observers to be able to start/stop in reaction to a state change, so our prior concurrency solution is insufficient because that will encounter a concurrent mutation error. CopyOnWrite is the easy solution (converting to Rx is the better long term, but more complex?)

* Convert the callback type for state observers from a two-arg key/value thing, which was confusing, to a strongly typed data class, left the old one in so this isn't a breaking change, even if it is just core

* IAF | Persisting the webview after close (#270)

* Move thread util to core package so it can be shared

* Keep the webview in memory when detaching (i.e. after closing)

* Add company ID observer to re-initialize the webview when company changes

* Add unregister and reinitialize forms API methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants