mapbox / mapbox/mapbox-maps-android

rememberGeoJsonSourceState causes transaction too large exception when saving state

Open
#2,465 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle: compose
Dominant language
Kotlin
Stars
578
Forks
161
PR merge metrics
No merged PRs in 30d

Description

## Environment

- Android OS version: any
- Devices affected: any
- Maps SDK Version: 11.6.0

## Observed behavior and steps to reproduce

- Remember a lot of complicated geometry using `rememberGeoJsonSourceState`
- Pause the app by backgrounding it
- Experience TransacationTooLarge crash when compose tries to persist the geometry into a bundle

We are loading some pretty complex geometry (testing with 1175 features) and following the examples, I tried using `rememberGeoJsonSourceState` in compose. However, under the hood, this function uses `rememberSaveable` which tries to persist all of those features to a bundle to save their state when the activity is paused. This of course causes a crash for our use case which was a bit tricky to debug because it was not immediately clear why the bundle was so large until we dug into the code.

Would it be reasonable to suggest making separate functions for `rememberGeoJsonSourceState` and `rememberGeoJsonSourceStateSaveable`? For our use case we just implemented a non-saveable version.

## Expected behavior

Don't crash when saving state

## Notes / preliminary analysis

## Additional links and references

```
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 687388 bytes
at android.app.ActivityClient.activityStopped(ActivityClient.java:87)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: android.os.TransactionTooLargeException: data parcel size 687388 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:571)
at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1315)
at android.app.ActivityClient.activityStopped(ActivityClient.java:84)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7870) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the implementation of rememberGeoJsonSourceState and inspect its use of rememberSaveable. Reproduce the issue with a large GeoJSON source, such as the reported 1175 features, then background the app. Done means saving state no longer causes a TransactionTooLargeException while the reported state behavior remains understood and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.