Skip to content

Improve stack trace when targeting WebGL #2091

Closed

Description

@dryyy27

Does it support the WebGL platform for WeChat mini-game development?

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 1, 2025
  2. bruno-garcia commented on Apr 2, 2025

    @bruno-garcia
    Member

    It does support webgl. but wechat specifically I'm not sure. could you try and let us know?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 2, 2025
  4. added theissue type on Apr 3, 2025
  5. dryyy27 commented on Apr 7, 2025

    @dryyy27
    Author

    But when I try to build a webgl package and display it on a web page, the stack cannot be displayed. Is there any step that is not executed?
    And Does it support crash log capture for webgl? When I enter the crash command of unity, there is no log capture.

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 7, 2025
  7. bitsandfoxes commented on Apr 8, 2025

    @bitsandfoxes
    Contributor

    Can you provide a sample for us to look at? When running the SDK's sample game, I do see the stack trace getting reported.

  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 8, 2025
  9. dryyy27 commented on Apr 9, 2025

    @dryyy27
    Author

    Demo: https://github.com/dryyy27/SentryDemo.git.
    I deleted the dsn, auth, project and organization.
    When I switch the platform to Linux or Android, the stack can be displayed

  10. 47 remaining items

  11. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 30, 2025
  12. added
    Bug
    on Apr 30, 2025
  13. bitsandfoxes commented on May 2, 2025

    @bitsandfoxes
    Contributor

    I'll have to try and check the conditions under which we can reliably grab and parse the stacktrace and then put together a PR.

  14. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 2, 2025
  15. bitsandfoxes commented on May 5, 2025

    @bitsandfoxes
    Contributor

    So after digging through it there are two issues tied to the `exceptionSupport:

    PlayerSettings.WebGL.exceptionSupport Limitations

    None

    Not supported. See #2141 for more details.

    Explicitly Thrown Exceptions Only

    Captures and reports exceptions but misses stacktrace.

    Full Without Stacktrace

    Captures and reports exceptions but misses stacktrace.

    Full With Stacktrace

    Captures and reports exception and provides a stacktrace (albeit with no line numbers due to lack of IL2CPP backend availability)

    Failing to create a new StackTrace

    This is happening when setting to Explicitly Thrown Exceptions Only and Full Without Stacktrace.
    The SDK fails trying to create a new SentryStackTrace the SDK fails with Could not resolve stack frame. This is due to the DebugStackTrace failing to create a managed frame. It relies on the following snippet used in the AotHelper

    var stackTrace = new StackTrace(false);
    return stackTrace.GetFrame(0)?.GetMethod() is null;
    

    To resolve this we could provide our own dedicated WebGLStackTraceFactory to create a new frame and fall back on stackFrame.ToString() instead of doing nothing. And probably skip a whole lot of other, for WebGL unnecessary checks i.e.

    if (CreateFrame(stackFrame) is { } frame)
    {
        yield return frame;
    }
    else
    {
        yield return new SentryStackFrame { Function = stackFrame.ToString() };
    }
    

    LogError events missing stacktrace

    The missing stacktrace also mentioned in #2091 (comment) is also related to the PlayerSettings.WebGL.exceptionSupport. When setting to FullWithStacktrace the SDK is able to provide stacktraces for these events as well. Set to any other option Unity does not pass down a stacktrace to the logging integration and we'd need to create a new stacktrace, bringing us back to the point above.

    Recommendation

    The current recommendation is to set PlayerSettings.WebGL.exceptionSupport to Full With Stacktrace to get the most out of the SDK. Anything else will require us to build a WebGL specific integration to better handle those cases.

  16. changed the issue type fromtoon May 5, 2025
  17. added
    Improvement
    and removed
    Bug
    on May 20, 2025
  18. changed the title [-]The webgl platform cannot display stack information[/-] [+]Improve stack trace when targeting `WebGL`[/+] on May 20, 2025
  19. bitsandfoxes commented on Nov 12, 2025

    @bitsandfoxes
    Contributor

    Superseded by #2415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementUnity

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions