Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session Replay - App Crash when open the web-page #14

Open
TomFluentjoy opened this issue Oct 17, 2024 · 1 comment
Open

Session Replay - App Crash when open the web-page #14

TomFluentjoy opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@TomFluentjoy
Copy link

TomFluentjoy commented Oct 17, 2024

Expected Behavior

The app should open the web page (we are using the WebKit) normally

Current Behavior

The app crashed instantly right after opening the WebKit

Screenshot 2024-10-18 at 13 25 01

Possible Solution

Steps to Reproduce

  1. Open the app

  2. Open the internal web page which are using the web kit
    `class TermsPagesViewController: UIViewController, WKNavigationDelegate {

    var termView = WKWebView()

    var backBtn = UIImageView()

    var url = "https://www.fluentjoy.com/terms-of-use/"

    var loader = UIActivityIndicatorView()

    override func viewDidLoad() {
    super.viewDidLoad()

     view.addSubview(termView)
     view.addSubview(backBtn)
     view.addSubview(loader)
     
     loader.style = .large
     
     backBtn.image = UIImage(named: "back_white")
     backBtn.translatesAutoresizingMaskIntoConstraints = false
     backBtn.widthAnchor.constraint(equalToConstant: 30).isActive = true
     backBtn.layer.contentsGravity = .resizeAspect
     backBtn.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 10).isActive = true
     backBtn.bottomAnchor.constraint(equalTo: self.view.topAnchor, constant: 100).isActive = true
    
     let backBtnTap = UITapGestureRecognizer(target: self, action: #selector(goBack))
     backBtn.addGestureRecognizer(backBtnTap)
     backBtn.isUserInteractionEnabled = true
     
     guard let url = URL(string: url) else {
         return
     }
     termView.navigationDelegate = self
     loader.isHidden = false
     loader.startAnimating()
     termView.load(URLRequest(url: url))
    

    }`

Environment

  • SDK Version:
    Amplitude: 8.22.0
    Session Replay: 0.0.9
  • OS Info:
@TomFluentjoy TomFluentjoy added the bug Something isn't working label Oct 17, 2024
@crleona
Copy link
Collaborator

crleona commented Nov 5, 2024

Hi @TomFluentjoy @tuanphambootloader ,

My apologies for the delayed response. I've been unable to reproduce the specific crash with a slightly modified version of your code (mostly just adding constraints):


import UIKit
import WebKit

class WebTestViewController: UIViewController, WKNavigationDelegate {

    var termView = WKWebView()

    var backBtn = UIImageView()

    var url = "https://www.fluentjoy.com/terms-of-use/"

    var loader = UIActivityIndicatorView()

    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(termView)
        view.addSubview(backBtn)
        view.addSubview(loader)

        loader.style = .large

        backBtn.image = UIImage(named: "back_white")
        backBtn.translatesAutoresizingMaskIntoConstraints = false
        backBtn.widthAnchor.constraint(equalToConstant: 30).isActive = true
        backBtn.layer.contentsGravity = .resizeAspect

        let backBtnTap = UITapGestureRecognizer(target: self, action: #selector(goBack))
        backBtn.addGestureRecognizer(backBtnTap)
        backBtn.isUserInteractionEnabled = true

        guard let url = URL(string: url) else {
            return
        }
        termView.navigationDelegate = self
        loader.isHidden = false
        loader.startAnimating()
        termView.load(URLRequest(url: url))
        termView.translatesAutoresizingMaskIntoConstraints = false

        NSLayoutConstraint.activate([
            termView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            termView.topAnchor.constraint(equalTo: view.topAnchor),
            termView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            termView.bottomAnchor.constraint(equalTo: view.bottomAnchor),

            backBtn.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            backBtn.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),

            loader.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            loader.centerYAnchor.constraint(equalTo: view.centerYAnchor),
        ])
    }

    @objc func goBack() {

    }
}

Is there any modification I would need to make to reproduce the crash?

Otherwise, could I please have you try v0.0.12 of the SDK? This resolves a memory leak and blocks processing of webviews by default. We plan to release more complete support for webviews later this quarter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants