Bug 205618 - Add support for iOS Simulator to ANGLE backend for WebGL
Summary: Add support for iOS Simulator to ANGLE backend for WebGL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: ANGLE (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kenneth Russell
URL:
Keywords: InRadar
Depends on: 205483
Blocks: webglangle 205781 209139
  Show dependency treegraph
 
Reported: 2019-12-28 13:59 PST by Kenneth Russell
Modified: 2020-10-26 13:10 PDT (History)
11 users (show)

See Also:


Attachments
Work-in-progress (16.41 KB, patch)
2019-12-30 13:46 PST, Kenneth Russell
no flags Details | Formatted Diff | Diff
Work-in-progress (16.67 KB, patch)
2019-12-30 18:02 PST, Kenneth Russell
no flags Details | Formatted Diff | Diff
Patch (25.24 KB, patch)
2019-12-31 19:28 PST, Kenneth Russell
no flags Details | Formatted Diff | Diff
Patch (25.33 KB, patch)
2020-01-03 14:01 PST, Kenneth Russell
dino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Russell 2019-12-28 13:59:02 PST
In bug 205483 WebKit's WebGL implementation was switched to use ANGLE on all Cocoa platforms except for the iOS simulator, because while IOSurfaces are now supported on that platform, [EAGLContext texImageIOSurface:...] is not. It looks like this can be emulated inside ANGLE's eglBindTexImage / eglReleaseTexImage entry points and thereby add support for the iOS simulator platform.
Comment 1 Kenneth Russell 2019-12-30 13:46:50 PST
Created attachment 386546 [details]
Work-in-progress
Comment 2 EWS Watchlist 2019-12-30 13:47:27 PST
Note that there are important steps to take when updating ANGLE. See http://trac.webkit.org/wiki/UpdatingANGLE
Comment 3 Kenneth Russell 2019-12-30 13:48:18 PST
This work-in-progress crashes the content process while running in the iOS Simulator. I'm still trying to figure out how to attach an lldb to the process in the simulator - dino@ pointed out that I should try attaching to com.apple.WebKit.WebContent.Development .
Comment 4 Kenneth Russell 2019-12-30 16:26:52 PST
Inserted a 20 second pause during GraphicsContext3D creation and got Xcode to attach to the com.apple.WebKit.WebContent.Development process when the simulator was launched from the command line. Stack trace follows. Still debugging.

#0	0x0000000235e1c411 in gl::LogMessage::~LogMessage() at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/common/debug.cpp:183
#1	0x0000000235e1c1d5 in gl::LogMessage::~LogMessage() at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/common/debug.cpp:159
#2	0x0000000236287d43 in gl::Texture::getSamples(gl::TextureTarget, unsigned long) const at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Texture.cpp:958
#3	0x000000023628d6d4 in gl::Texture::getAttachmentSamples(gl::ImageIndex const&) const at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Texture.cpp:1628
#4	0x0000000235d46058 in gl::FramebufferAttachment::getResourceSamples() const at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.h:256
#5	0x0000000235d40450 in gl::FramebufferAttachment::getSamples() const at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.h:250
#6	0x0000000235ffd73f in gl::(anonymous namespace)::CheckAttachmentSampleCompleteness(gl::Context const*, gl::FramebufferAttachment const&, bool, Optional<int>*, Optional<bool>*, Optional<int>*) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Framebuffer.cpp:189
#7	0x0000000235ffc0ee in gl::Framebuffer::checkStatusWithGLFrontEnd(gl::Context const*) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Framebuffer.cpp:1117
#8	0x0000000235ffbcf7 in gl::Framebuffer::checkStatusImpl(gl::Context const*) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Framebuffer.cpp:1061
#9	0x0000000235dc90bf in gl::Framebuffer::checkStatus(gl::Context const*) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Framebuffer.h:283
#10	0x0000000235dc8ee2 in gl::Context::checkFramebufferStatus(unsigned int) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libANGLE/Context.cpp:6168
#11	0x0000000235eaea0f in gl::CheckFramebufferStatus(unsigned int) at /Users/kbr/src/iOSWebKit/Source/ThirdParty/ANGLE/src/libGLESv2/entry_points_gles_2_0_autogen.cpp:338
#12	0x00000002208af400 in WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(unsigned int, int, int) at /Users/kbr/src/iOSWebKit/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp:251
#13	0x00000002208af207 in WebCore::GraphicsContext3D::reshapeFBOs(WebCore::IntSize const&) at /Users/kbr/src/iOSWebKit/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp:216
#14	0x00000002208b0b70 in WebCore::GraphicsContext3D::reshape(int, int) at /Users/kbr/src/iOSWebKit/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp:578
#15	0x000000022320a03f in WebCore::WebGLRenderingContextBase::initializeNewContext() at /Users/kbr/src/iOSWebKit/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:783
#16	0x00000002231fd51d in WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase(WebCore::CanvasBase&, WTF::Ref<WebCore::GraphicsContext3D, WTF::DumbPtrTraits<WebCore::GraphicsContext3D> >&&, WebCore::GraphicsContext3DAttributes) at /Users/kbr/src/iOSWebKit/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:653
Comment 5 Kenneth Russell 2019-12-30 18:02:34 PST
Created attachment 386547 [details]
Work-in-progress
Comment 6 Kenneth Russell 2019-12-30 18:03:49 PST
Fixed the crash, which was caused by a mismatch between the use of the TEXTURE_2D and TEXTURE_RECTANGLE_ANGLE texture targets. (The same problem probably exists in the on-device iOS port.) Still doesn't render anything yet.
Comment 7 Kenneth Russell 2019-12-31 19:28:38 PST
Created attachment 386570 [details]
Patch
Comment 8 Kenneth Russell 2019-12-31 19:29:04 PST
The current patch
Comment 9 Kenneth Russell 2019-12-31 19:31:20 PST
Thanks to more hints from dino@, the current patch seems to be working! At least, it did in a debug build just before rebasing on ToT. Will test more locally.

dino@, could you please help testing this on-device and making sure it doesn't break that code path? I believe it should only make that code path more correct, rather than regressing anything. Thanks!
Comment 10 Kenneth Russell 2020-01-03 14:01:23 PST
Created attachment 386713 [details]
Patch
Comment 11 Kenneth Russell 2020-01-03 14:02:37 PST
Fixed the compile failure on iOS and changed the newly-allocated enum for the usage hint.
Comment 12 Dean Jackson 2020-01-05 09:59:04 PST
Committed r254036: <https://trac.webkit.org/changeset/254036>
Comment 13 Radar WebKit Bug Importer 2020-01-05 10:00:18 PST
<rdar://problem/58325954>