Bug 230472 - ANGLE Metal: single-component swizzles do not compile
Summary: ANGLE Metal: single-component swizzles do not compile
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kimmo Kinnunen
URL:
Keywords: InRadar
: 230949 234208 234218 234219 240433 (view as bug list)
Depends on:
Blocks: 240433
  Show dependency treegraph
 
Reported: 2021-09-19 23:07 PDT by Raúl
Modified: 2022-06-23 12:11 PDT (History)
11 users (show)

See Also:


Attachments
Shader code files (4.59 KB, application/x-zip-compressed)
2021-09-19 23:07 PDT, Raúl
no flags Details
translation and errors (20.16 KB, text/plain)
2021-09-20 01:10 PDT, Kimmo Kinnunen
no flags Details
Patch (10.24 KB, patch)
2021-09-20 11:52 PDT, Kimmo Kinnunen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raúl 2021-09-19 23:07:54 PDT
Created attachment 438639 [details]
Shader code files

Hello,

We have an application for a few years now that runs over blend4web 17.12.
Here a link for reference: https://testios15.made-to-order.com/
There we have slightly modified the b4w engine to show extra debug log.
The main error from B4W says: Shader compilation/linking error: postprocessing/postprocessing.glslv, postprocessing/postprocessing.glslf, materials: ""
Throwing some logs around, we see that at the "init_shader" function, "gl.getError()" returns a "INVALID_OPERATION" after "gl.linkProgram".
Then, "gl.getProgramInfoLog(program)" shows a not very useful but human readable error: Internal error compiling shader with Metal backend. Please submit this shader, or website as a bug to https://bugs.webkit.org

Honestly, I am no GLSL expert (nor beginner), although I have been trying to mess with the shader, and even removing all "postprocessing.glslf" logic (leaving only an assignment to a plain color) won't work.
I know this one is going to be tricky, as there is no life over blend4web forums for a while now, and their shaders and logic are quite difficult to play with, but anyway I thought of letting you know just in case.
You can find attached the main shader files; they use a lot of different files, but in this specific error those are the ones I think are directly involved.
I have included as well a "directives.js", as they change on the fly the code depending on webgl 1 or 2 version (the log for the iPad shows me it is using the webgl 1 version).

Please let me know if I can help somehow.

Best regards.
Comment 1 Kimmo Kinnunen 2021-09-20 01:10:28 PDT
Created attachment 438645 [details]
translation and errors

program_source:106:12: error: no matching constructor for initialization of 'ANGLE_VectorElemRef<float, 3>'
    return ANGLE_VectorElemRef<T, N>(vec, is);
           ^                         ~~~~~~~
program_source:216:6: note: in instantiation of function template specialization 'ANGLE_swizzle_ref<float, 3>' requested here
  aW(ANGLE_swizzle_ref(aQ, 0));
     ^
program_source:65:5: note: candidate constructor not viable: no known conversion from 'const int [1]' to 'int' for 2nd argument
    ANGLE_VectorElemRef(thread metal::vec<T, N> &vec, int index)
    ^
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
struct ANGLE_VectorElemRef
       ^
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
program_source:59:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
Comment 2 Kimmo Kinnunen 2021-09-20 05:50:42 PDT
Thanks for the report. Will post a fix shortly.
Comment 3 Radar WebKit Bug Importer 2021-09-20 09:51:48 PDT
<rdar://problem/83310780>
Comment 4 Kimmo Kinnunen 2021-09-20 11:52:33 PDT
Created attachment 438705 [details]
Patch
Comment 5 EWS Watchlist 2021-09-20 11:53:54 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 6 EWS 2021-09-20 22:27:17 PDT
Committed r282800 (241932@main): <https://commits.webkit.org/241932@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 438705 [details].
Comment 7 Eric 2021-09-29 03:36:45 PDT
Same issue with iOS and iPadOS 15.1 Beta 2 Safari.
In MacOS Safari, FireFox, Chrome last versions works perfectly.
Most of blend4web examples in they website don't work to.
https://www.blend4web.com/apps/code_snippets/code_snippets.html?scene=material_api
Console log:
[Error] B4W ERROR: Shader compilation/linking error: main.glslv, main_stack.glslf, materials: "DEFAULT"
	d (output.5e52a835b47f.js:1:1026)
	Q (output.5e52a835b47f.js:29:288)
	ia (output.5e52a835b47f.js:14:1625)
	(función anónima) (output.5e52a835b47f.js:16:470)
	(función anónima) (output.5e52a835b47f.js:65:1694)
	a (output.5e52a835b47f.js:94:1050)
	(función anónima) (output.5e52a835b47f.js:94:2760)
	(función anónima) (output.5e52a835b47f.js:65:1526)
	aa (output.5e52a835b47f.js:87:888)
Comment 8 Kimmo Kinnunen 2021-09-29 11:00:19 PDT
*** Bug 230949 has been marked as a duplicate of this bug. ***
Comment 9 Kimmo Kinnunen 2021-09-29 11:00:51 PDT
Unfortunately the problem is present in the currently released iOS, but will be fixed in one of the upcoming releases.
If you are able to use a workaround, you could change the variables passed to inout parameters of the functions to not refer to swizzles.

before:
void f(inout float a) { ... }
void main() {
 vec3 myvec = ...;
 f(myvec.x);
}

after:
void f(inout float a) { ... }
void main() {
 vec3 myvec = ...;
 float myfloat = myvec.x;
 f(myfloat);
 myvec.x = myfloat;
}
Comment 10 Raúl 2021-09-29 22:50:39 PDT
Many thanks for the fix and follow up on this.
The example code for the workaround doesn't seem to fit my needs though.
It may be related to the fact that changing B4W engine is hard, but I don't see any function calls with swizzles, and I even removed all the code from the problematic shader (leaving only a plain out color), and it is still not working.
So I hope it will be solved with this fix when actually released.
Comment 11 Eric 2021-10-07 02:39:12 PDT
info: iOS 15.1 Beta 3 still has the issue.

thanks.
Comment 12 Raúl 2021-10-19 23:10:00 PDT
Hi,

iOS Beta 5 still not working.
Anyone has any insights for when this would be added?
Or at least, can you confirm the link I shared (https://testios15.made-to-order.com/) works with the patch?
Our company really depends on our product configurator working properly on all devices, and it is becoming a huge concern for us now.
Comment 13 Kimmo Kinnunen 2021-10-27 06:42:39 PDT
(In reply to Raúl from comment #12)
> Hi,
> 
> iOS Beta 5 still not working.
> Anyone has any insights for when this would be added?
> Or at least, can you confirm the link I shared
> (https://testios15.made-to-order.com/) works with the patch?

I can confirm the site works with WebKit trunk version with the patch.
I cannot confirm when the patch is released until it is released.

For workaround, you could try to apply the suggestion about not using single value swizzles for targets of inout parameters, or ask the engine vendor to apply the workaround.
Comment 14 Eric 2021-11-12 04:03:51 PST
Solved on iOS 15.2 Beta 2, thanks you.
Comment 15 Raúl 2021-12-09 23:18:45 PST
Hi,

Thanks for everything, it seems the fix is coming soon to iOS.

I have detected the same error on the macOS 15 beta, not sure if it is exactly the same error as I cannot see the full log as you do, but it fails at the same shader so it might be the same kind of error.
Not sure if I should post another bug for this, or maybe you can take a look directly.

Many thanks.
Comment 16 Raúl 2021-12-09 23:23:09 PST
BTW, it seems to work on Chrome but not Safari, in case that helps.
Comment 17 Kimmo Kinnunen 2021-12-09 23:31:30 PST
(In reply to Raúl from comment #15)
> Hi,
> 
> Thanks for everything, it seems the fix is coming soon to iOS.
> 
> I have detected the same error on the macOS 15 beta, not sure if it is
> exactly the same error as I cannot see the full log as you do, but it fails
> at the same shader so it might be the same kind of error.
> Not sure if I should post another bug for this, or maybe you can take a look
> directly.

This fix for this particular issue, single-component swizzles do not compile, will also be fixed in one of the upcoming macOS releases. If you're reporting that your specific site that failed on iOS due to this issue is also failing on macOS, most likely it is the same issue and does not need to be reported.

If you are observing an issue in some other content that probably is not due to this same root cause, feel free to file another issue. Alternatively please comment in this bug so I can file the issue. Please provide details on which site or preferably add some reproduction content. Please describe the hardware and software versions being used.

The shader compilation bug error message is currently the same for all shader compilation bugs.
Comment 18 Kimmo Kinnunen 2021-12-13 00:01:43 PST
*** Bug 234219 has been marked as a duplicate of this bug. ***
Comment 19 Kimmo Kinnunen 2021-12-13 00:07:13 PST
*** Bug 234218 has been marked as a duplicate of this bug. ***
Comment 20 Kimmo Kinnunen 2021-12-13 00:10:42 PST
*** Bug 234208 has been marked as a duplicate of this bug. ***
Comment 21 Kimmo Kinnunen 2021-12-13 00:11:43 PST
Marking this as fixed again. For new errors we should have new bug entries.
Comment 22 Brent Fulgham 2022-06-23 12:11:51 PDT
*** Bug 240433 has been marked as a duplicate of this bug. ***