Bug 262097

Summary: REGRESSION (iOS 17): 100x performance degradation of Range.setStart() after repeating DOM operation.
Product: WebKit Reporter: Takao Baba <baba>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cdumez, megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: iPhone / iPad   
OS: iOS 17   
Attachments:
Description Flags
testcase
none
result
none
result movie on iPhone 13 none

Description Takao Baba 2023-09-25 22:19:44 PDT
Created attachment 467868 [details]
testcase

# Steps to reproduce

1. Open attached sample.html
2. Wait tens of seconds.

# Expected behavior

The processing time shown in "h1" tag is stable, about 20-100ms.

# Actual behavior

On iOS 17 Safari, the processing time is going to be about 10-100 times slower (about 1000-5000ms), after about 20 seconds.
The performance is good in first few seconds.

# Note

The sample repeats creating a range, modifying the DOM and revert them many times.
According to the inspector, "Range.setStart()" in "releaseRange()" takes long time.

The issue does not occur on iOS 16.2 and Safari Technology Preview 17.0 on macOS.
Comment 1 Takao Baba 2023-09-25 22:20:08 PDT
Created attachment 467869 [details]
result
Comment 2 Radar WebKit Bug Importer 2023-09-26 09:28:30 PDT
<rdar://problem/116059496>
Comment 3 Alexey Proskuryakov 2023-09-26 11:27:06 PDT
Thank you for the report. FWIW, I cannot reproduce this on an iPhone.
Comment 4 Takao Baba 2023-09-26 18:15:44 PDT
Thank you for the confirmation. In my company, the issue is able to reproduce at least the following environment.

- iPhone SE2 iOS 17.0.2
- iPhone 13 iOS 17.0.1
- iPad 9th iPadOS 17.0
- iPad Simulator iPadOS 17.0 on M1 mac mini
Comment 5 Takao Baba 2023-09-26 18:18:32 PDT
Created attachment 467886 [details]
result movie on iPhone 13