Bug 233706 - [Model] Add load and error events to distinguish resource load from model readiness
Summary: [Model] Add load and error events to distinguish resource load from model rea...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antoine Quint
URL:
Keywords: InRadar
Depends on: 234153
Blocks: 233643
  Show dependency treegraph
 
Reported: 2021-12-01 08:21 PST by Antoine Quint
Modified: 2022-01-23 15:39 PST (History)
7 users (show)

See Also:


Attachments
Patch (24.75 KB, patch)
2021-12-07 08:13 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch (25.20 KB, patch)
2021-12-07 09:34 PST, Antoine Quint
cdumez: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (26.34 KB, patch)
2021-12-08 01:33 PST, Antoine Quint
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (37.92 KB, patch)
2021-12-09 03:14 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch for landing (42.29 KB, patch)
2021-12-13 13:17 PST, Antoine Quint
no flags Details | Formatted Diff | Diff
Patch for landing (42.19 KB, patch)
2022-01-23 12:24 PST, Antoine Quint
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Quint 2021-12-01 08:21:06 PST
As it stands <model> elements have a "ready" promise, which resolves once the resource has been loaded. However, this promise should be used when the <model> is fully ready, and this is done on macOS and iOS asynchronously after the resource has been loaded. So we should have "load" and "error" events and a "complete" property to match <img> to identify resource load, and use the "ready" promise for when the model is fully ready and its various APIs safely usable.
Comment 1 Radar WebKit Bug Importer 2021-12-01 08:21:31 PST
<rdar://problem/85922697>
Comment 2 Antoine Quint 2021-12-07 08:13:52 PST
Created attachment 446174 [details]
Patch
Comment 3 Chris Dumez 2021-12-07 08:27:22 PST
It seems you are not overriding virtualHasPendingActivity() and I believe that is an issue

You need to override it to keep the HTMLModelElement JS wrapper alive as long as you may fire load/error events on it

queueTaskToDispatchEvent() keeps the JS wrapper alive between the call to queueTaskToDispatchEvent() and the point where the event actually gets fired. However, nothing seems to make sure your JS wrapper says alive until you eventually call queueTaskToDispatchEvent().
Comment 4 Antoine Quint 2021-12-07 09:34:03 PST
Created attachment 446189 [details]
Patch
Comment 5 Antoine Quint 2021-12-07 09:35:54 PST
(In reply to Chris Dumez from comment #3)
> It seems you are not overriding virtualHasPendingActivity() and I believe
> that is an issue
> 
> You need to override it to keep the HTMLModelElement JS wrapper alive as
> long as you may fire load/error events on it
> 
> queueTaskToDispatchEvent() keeps the JS wrapper alive between the call to
> queueTaskToDispatchEvent() and the point where the event actually gets
> fired. However, nothing seems to make sure your JS wrapper says alive until
> you eventually call queueTaskToDispatchEvent().

Thanks for pointing that out. The new patch has an implementation for virtualHasPendingActivity() and calls suspendIfNeeded() in the create() method.
Comment 6 Chris Dumez 2021-12-07 09:41:23 PST
Comment on attachment 446189 [details]
Patch

r=me
Comment 7 Antoine Quint 2021-12-08 01:33:26 PST
Created attachment 446333 [details]
Patch for landing
Comment 8 Antoine Quint 2021-12-09 03:14:31 PST
Created attachment 446513 [details]
Patch for landing
Comment 9 Antoine Quint 2021-12-10 00:15:22 PST
Committed r286836 (245069@trunk): <https://commits.webkit.org/245069@trunk>
Comment 10 Antoine Quint 2021-12-10 00:19:39 PST
A note to bot watchers: the existing test model-element/model-element-contents-layer-updates-with-clipping.html was modified as part of this patch and the iOS-15-Simulator-WK2-Tests-EWS bot saw flakiness with it as part of the run-layout-tests-in-stress-mode step. Subsequent test runs did not see such an issue. I tried to run the test locally with the iPhone 8 simulator using the iOS 12.2 SDK and did not see an issue running the test with `--ios-simulator --release --iterations=100`. I also tried with `--run-singly`. In case you see some flakiness with this test, please mark it as flaky for now and file a bug so that I may investigate.
Comment 11 Antoine Quint 2021-12-10 00:20:06 PST
That would be the iOS 15.2 SDK, not 12.2.
Comment 12 WebKit Commit Bot 2021-12-10 09:23:52 PST
Re-opened since this is blocked by bug 234153
Comment 13 Antoine Quint 2021-12-10 09:26:33 PST
There two types of failures with the changed or new tests. On iOS, you can see some flakiness by running:

run-webkit-tests --no-build --release --ios-simulator --exit-after-n-failures 1 --skip-failing-tests --iterations 100 LayoutTests/model-element/model-element-contents-layer-updates.html LayoutTests/model-element/model-element-contents-layer-updates-with-clipping.html LayoutTests/model-element/model-element-graphics-layers-opacity.html LayoutTests/model-element/model-element-error-and-load-events.html LayoutTests/model-element/model-element-graphics-layers.html LayoutTests/model-element/model-element-ready.html

On macOS, you can see some crashes by running:

rwt --debug --iterations=100 model-element --exit-after-n-failures=1
Comment 14 Antoine Quint 2021-12-13 13:17:23 PST
Created attachment 447050 [details]
Patch for landing
Comment 15 Antoine Quint 2022-01-23 12:24:50 PST
Created attachment 449762 [details]
Patch for landing
Comment 16 EWS 2022-01-23 13:51:36 PST
Committed r288424 (246315@main): <https://commits.webkit.org/246315@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449762 [details].