Yjs: data seems to be lost when reopening the app

Hello! :smiley:

I’m facing an issue with a WebXDC app that uses preact and yjs.

The problem

Any changes that are made seem to be lost when closing and opening the app again. It doesn’t matter how much time I leave the app open.

Making any changes with the app open, either from that instance or another, brings back the changes that were lost.

I don’t see any errors in the web browser console when running the app with webxdc-dev run dist or when opening the Developer Tools from Delta Chat Desktop.

How to reproduce the problem

I created a minimal WebXDC example app that reproduces the issue.

This is the repository of the minimal WebXDC example app: uuid-manager. Here you have the built app, ready to share with Delta Chat:
app.xdc (30.5 KB).

I’ve only seen it happen with Delta Chat Desktop (2.11.1) and when using webxdc-dev run dist - it happens almost every time. Delta Chat Android seems unafected: I can’t reproduce it there. (This is both for the example app and the actual app.)

To reproduce the problem:

  1. Open the app.
  2. Add some UUIDs.
  3. Delta Chat Desktop: close the app. webxdc-dev: press the stop (square) button.
  4. Delta Chat Desktop: open the app again. webxdc-dev: press the play (triangle) button.

The UUIDs that have been added are missing. In the web browser console there aren’t any errors. If you add another UUID now, then the previous ones and the new one appear. There are logs that show when UUIDs are processed.

Why is this happening? Am I incorrectly creating and using yjs collections? Am I misusing preact?