WKWebView backForwardList getting messed up when going back


in my webapp I try to establish going back and forth via swipe gestures.

Using WKWebView this should be as simple as

webView.allowsBackForwardNavigationGestures = true

While navigating through the web content the navigation stack webView.backForwardList is filled up as expected.

URL1 -> URL2 -> URL3 -> URL4

leads to

webView.backForwardList.item(at:0) -> URL4

webView.backForwardList.item(at:-1) -> URL3

webView.backForwardList.item(at:-2) -> URL2

webView.backForwardList.item(at:-3) -> URL1

but as soon as I try to go back in history by either using a swipe gesture or manually triggering webView.goBack() the navigation stack gets messed up and enters a loop.

Going back from URL4 to URL3 in history leads to webView.backForwardList.item(at:-1) -> URL4 and not URL2 as I would expect it.

So whenever I go back the navigation stack gets stuck in a loop between the last two URLs.

Does anyone have an idea how to fix this?

Thank you