Bug 252493

Summary: REGRESSION (16.4 beta): Tensorflow / Shader Issue
Product: WebKit Reporter: M <heystoneybatter>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: dino, kbr, kkinnunen, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: iOS 16   

Description M 2023-02-17 10:33:52 PST
I noticed some issues in the new iOS 16.4 beta 1 (as well as Safari Preview 16.4 on desktop) regarding some Tensorflow models.

This demo for example works in the current live version(s) of Safari and iOS 16.3:
https://storage.googleapis.com/tfjs-models/demos/body-pix/index.html

It doesn't load now in 16.4 and also does not show an error in console.

I have a local demo (that I will try and publish and update here) that shows a type error when running the segmentation model in 16.4 that I believe is originating in a shader.
Comment 1 M 2023-02-17 18:58:39 PST
Here is a basic demo that demonstrates the issue mentioned:
https://testing-3ix.pages.dev

The expected behavior is that a person is found in the image via Tensorflow/Bodypix. In all prior versions of Safari (iOS, iPadOS, Desktop), this succeeds. In iOS 16.4 Beta 1 and Safari Technology Preview (Release 163, 16.4) the process does not complete and actually does not create an error either.
Comment 2 Kimmo Kinnunen 2023-02-18 04:15:08 PST
Thanks for the report. The page appears to hang the web content process. Will investigate further.
Comment 3 Alexey Proskuryakov 2023-02-20 10:58:27 PST
rdar://105684718
Comment 4 Kimmo Kinnunen 2023-02-24 09:42:39 PST
For the testing-3ix page I get a WebContent process hang and a inspector crash
Would this be some other sort of corruption, maybe wasm?

frame #0: 0x0000000280c0f934 WebCore`WebCore::Node::treeScope(this=0x0000000000000000) const at Node.h:386:9
    frame #1: 0x0000000280c0f7bc WebCore`WebCore::Node::document(this=0x0000000000000000) const at Node.h:382:41
    frame #2: 0x00000002841cad08 WebCore`WebCore::InspectorCanvasAgent::requestNode(this=0x000000010702d1e0, canvasId={ length = 10, contents = 'canvas:0.3' }) at InspectorCanvasAgent.cpp:182:89
    frame #3: 0x0000000135a4ffd0 JavaScriptCore`Inspector::CanvasBackendDispatcher::requestNode(this=0x00000001070c9b00, protocol_requestId=77, protocol_parameters=0x000000016bd636c0) at InspectorBackendDispatchers.cpp:1356:28
    frame #4: 0x0000000135a4fa30 JavaScriptCore`Inspector::CanvasBackendDispatcher::dispatch(this=0x00000001070c9b00, protocol_requestId=77, protocol_method={ length = 11, contents = 'requestNode' }, protocol_message=0x000000016bd63968) at InspectorBackendDispatchers.cpp:1298:5
    frame #5: 0x0000000135a41b74 JavaScriptCore`Inspector::BackendDispatcher::dispatch(this=0x0000000107118400, message={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' }) at InspectorBackendDispatcher.cpp:183:27
    frame #6: 0x000000028410fd54 WebCore`WebCore::InspectorController::dispatchMessageFromFrontend(this=0x000000010700cb80, message={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' }) at InspectorController.cpp:417:26
    frame #7: 0x0000000119d83794 WebKit`WebKit::WebPageInspectorTarget::sendMessageToTargetBackend(this=0x00000001071182c8, message={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' }) at WebPageInspectorTarget.cpp:69:50
    frame #8: 0x0000000119d83ba0 WebKit`WebKit::WebPageInspectorTargetController::sendMessageToTargetBackend(this=0x00000001071182c0, targetId={ length = 7, contents = 'page-14' }, message={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' }) at WebPageInspectorTargetController.cpp:88:13
    frame #9: 0x000000011a2e3b60 WebKit`WebKit::WebPage::sendMessageToTargetBackend(this=0x0000000161823e08, targetId={ length = 7, contents = 'page-14' }, message={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' }) at WebPage.cpp:3544:34
    frame #10: 0x000000011a398954 WebKit`auto void IPC::callMemberFunction<WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String> >(this=0x000000016bd63cc0, args={ length = 7, contents = 'page-14' }, args={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' })(WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String>&&)::'lambda'(auto&&...)::operator()<WTF::String, WTF::String>(auto&&...) const at HandleMessage.h:136:13
    frame #11: 0x000000011a39888c WebKit`decltype(__f=0x000000016bd63cc0, __args={ length = 7, contents = 'page-14' }, __args={ length = 74, contents = '{"id":77,"method":"Canvas.requestNode","params":{"canvasId":"canvas:0.3"}}' })(std::declval<WTF::String>(), std::declval<WTF::String>())) std::__1::__invoke[abi:v15006]<void IPC::callMemberFunction<WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String> >(WebKit::WebPage*, void (WebKit::WebPage::*)(WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String>&&)::'lambda'(auto&&...), WTF::String, WTF::String>(WebKit::WebPage&&, WTF::String&&, WTF::String&&) at invoke.h:394:23
    frame #12: 0x000000011a398854 WebKit`decltype(__f=0x000000016bd63cc0, __t=size=2, (null)=__tuple_indices<0UL, 1UL> @ 0x000000016bd63c7f) std::__1::__apply_tuple_impl[abi:v15006]<void IPC::callMemberFunction<WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String> >(WebKit::WebPage*, void (WebKit::WebPage::*)(WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String>&&)::'lambda'(auto&&...), std::__1::tuple<WTF::String, WTF::String>, 0ul, 1ul>(WebKit::WebPage&&, WebKit::WebPage&&, std::__1::__tuple_indices<0ul, 1ul>) at tuple:1789:1
    frame #13: 0x000000011a398804 WebKit`decltype(__f=0x000000016bd63cc0, __t=size=2) std::__1::apply[abi:v15006]<void IPC::callMemberFunction<WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String> >(WebKit::WebPage*, void (WebKit::WebPage::*)(WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String>&&)::'lambda'(auto&&...), std::__1::tuple<WTF::String, WTF::String> >(WebKit::WebPage&&, WebKit::WebPage&&) at tuple:1798:1
    frame #14: 0x000000011a3987d4 WebKit`void IPC::callMemberFunction<WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String> >(object=0x0000000161823e08, function=2c 3b 2e 1a 01 80 0a 98 00 00 00 00 00 00 00 00, tuple=size=2)(WTF::String const&, WTF::String const&), std::__1::tuple<WTF::String, WTF::String>&&) at HandleMessage.h:134:5
    frame #15: 0x000000011a3584bc WebKit`void IPC::handleMessage<Messages::WebPage::SendMessageToTargetBackend, WebKit::WebPage, WebKit::WebPage, void (WTF::String const&, WTF::String const&)>(connection=0x000000010703c840, decoder=0x000000010711b380, object=0x0000000161823e08, function=2c 3b 2e 1a 01 80 0a 98 00 00 00 00 00 00 00 00)(WTF::String const&, WTF::String const&)) at HandleMessage.h:236:9
    frame #16: 0x000000011a3509e4 WebKit`WebKit::WebPage::didReceiveWebPageMessage(this=0x0000000161823e08, connection=0x000000010703c840, decoder=0x000000010711b380) at WebPageMessageReceiver.cpp:489:16
    frame #17: 0x000000011a2eda08 WebKit`WebKit::WebPage::didReceiveMessage(this=0x0000000161823e08, connection=0x000000010703c840, decoder=0x000000010711b380) at WebPage.cpp:5519:5
    frame #18: 0x000000011a8a097c WebKit`IPC::MessageReceiverMap::dispatchMessage(this=0x00000001070409c8, connection=0x000000010703c840, decoder=0x000000010711b380) at MessageReceiverMap.cpp:129:26
    frame #19: 0x00000001199f9214 WebKit`WebKit::WebProcess::didReceiveMessage(this=0x0000000107040990, connection=0x000000010703c840, decoder=0x000000010711b380) at WebProcess.cpp:931:30
    frame #20: 0x000000011a874bec WebKit`IPC::Connection::dispatchMessage(this=0x000000010703c840, decoder=0x000000010711b380) at Connection.cpp:1197:15
    frame #21: 0x000000011a87507c WebKit`IPC::Connection::dispatchMessage(this=0x000000010703c840, message=IPC::Decoder @ 0x000000010711b380) at Connection.cpp:1245:9
    frame #22: 0x000000011a8753b8 WebKit`IPC::Connection::dispatchOneIncomingMessage(this=0x000000010703c840) at Connection.cpp:1310:5
    frame #23: 0x000000011a893094 WebKit`IPC::Connection::enqueueIncomingMessage(this=0x00000001071592b8)::$_17::operator()() const at Connection.cpp:1159:28
    frame #24: 0x000000011a892fd4 WebKit`WTF::Detail::CallableWrapper<IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_17, void>::call(this=0x00000001071592b0) at Function.h:53:39
    frame #25: 0x00000001363c05a4 JavaScriptCore`WTF::Function<void ()>::operator(this=0x000000016bd66310)() const at Function.h:82:35
    frame #26: 0x000000013437e96c JavaScriptCore`WTF::RunLoop::performWork(this=0x0000000107010100) at RunLoop.cpp:147:9
    frame #27: 0x0000000134382e98 JavaScriptCore`WTF::RunLoop::performWork(context=0x0000000107010100) at RunLoopCF.cpp:46:37
    frame #28: 0x0000000184252710 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    frame #29: 0x00000001842526a4 CoreFoundation`__CFRunLoopDoSource0 + 176
    frame #30: 0x0000000184252414 CoreFoundation`__CFRunLoopDoSources0 +
Comment 5 M 2023-03-06 01:39:08 PST
Thank you Kimmo for looking into this. I turned on tensorflow.js's debug mode as well on the test link (https://testing-3ix.pages.dev) in case that helps a bit more. It does seem to stall out very early in the process, but it seems odd that an error isn't produced.

Understand if this isn't answerable, but given the current release cycle, does this seem like something that might be addressed before the RC or should I explore other options? Thank you again for your help.