If I put the code for my UIBezierPath inside the draw(_ rect:) function I get these strange very thin black corners around the view and the tail. When dragging the view (e.g. within a presented view controller) these thin lines also start flickering. I assume it's a weird rendering bug. Does anyone know if there is a way to fix this?
To test this, just put the following view inside a view controller
class RenderingView: UIView {
		lazy var backgroundView: UIView = {
				let view = UIView()
				view.layer.cornerRadius = 8
				view.translatesAutoresizingMaskIntoConstraints = false
				return view
		}()
		private lazy var shadowView: UIView = {
				let view = UIView()
				view.translatesAutoresizingMaskIntoConstraints = false
				return view
		}()
		private lazy var textLabel: UILabel = {
				let label = UILabel()
				label.numberOfLines = 0
				label.textAlignment = .center
				label.translatesAutoresizingMaskIntoConstraints = false
				label.text = "Rendering Bug"
				return label
		}()
		override init(frame: CGRect) {
				super.init(frame: frame)
				setup()
		}
		required init?(coder: NSCoder) {
				fatalError("init(coder:) has not been implemented")
		}
		private func setup() {
				backgroundColor = .clear
				backgroundView.backgroundColor = .yellow
				layer.borderWidth = 0
				setupLayout()
		}
		private func setupLayout() {
				[shadowView, backgroundView, textLabel].forEach(addSubview)
				backgroundView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
				backgroundView.topAnchor.constraint(equalTo: topAnchor).isActive = true
				backgroundView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
				backgroundView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
				shadowView.leadingAnchor.constraint(equalTo: backgroundView.leadingAnchor).isActive = true
				shadowView.topAnchor.constraint(equalTo: backgroundView.topAnchor).isActive = true
				shadowView.trailingAnchor.constraint(equalTo: backgroundView.trailingAnchor).isActive = true
				shadowView.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor).isActive = true
				textLabel.leadingAnchor.constraint(equalTo: backgroundView.leadingAnchor, constant: 10).isActive = true
				textLabel.trailingAnchor.constraint(equalTo: backgroundView.trailingAnchor, constant: -10).isActive = true
				textLabel.topAnchor.constraint(equalTo: backgroundView.topAnchor, constant: 10).isActive = true
				textLabel.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -10).isActive = true
		}
		override func draw(_ rect: CGRect) {
				shapeBackground()
		}
		private func shapeBackground() {
				let tailLayer = CAShapeLayer()
				let bezierPath = UIBezierPath(roundedRect: CGRect(x: backgroundView.bounds.minX,
																													y: backgroundView.bounds.minY,
																													width: backgroundView.bounds.width,
																													height: backgroundView.bounds.height - 12),
																			cornerRadius: 8)
				let shadowBezierPath = UIBezierPath(roundedRect: CGRect(x: backgroundView.bounds.minX + 5,
																																y: backgroundView.bounds.minY + 10,
																																width: backgroundView.bounds.width - 10,
																																height: backgroundView.bounds.height - 12 - 10),
																						cornerRadius: 8)
				[bezierPath, shadowBezierPath].forEach {
						$0.move(to: CGPoint(x: backgroundView.bounds.midX - 12, y: backgroundView.bounds.maxY - 12))
						$0.addLine(to: CGPoint(x: backgroundView.bounds.midX, y: backgroundView.bounds.maxY))
						$0.addLine(to: CGPoint(x: backgroundView.bounds.midX + 12, y: backgroundView.bounds.maxY - 12))
						$0.fill()
						$0.close()
				}
				tailLayer.path = bezierPath.cgPath
				tailLayer.fillColor = UIColor.white.cgColor
				shadowView.layer.shadowPath = shadowBezierPath.cgPath
				shadowView.layer.cornerRadius = 8
				backgroundView.layer.masksToBounds = true
				backgroundView.layer.mask = tailLayer
		}
}
Post
Replies
Boosts
Views
Activity
It seems like a WKWebView doesn't handle 421 responses automatically.
What basically happened is the following:
The client requests a page at foo.example.com
During TLS negotiation, the server presents a certificate which is valid for both foo.example.com and bar.example.com (and the client accepts it). This could be done with a wildcard certificate or a SAN certificate.
The client reuses the connection to make a request for bar.example.com.
The server is unable or unwilling to support cross-domain connection reuse and serves HTTP 421.
The client does not automatically retry with a new connection.
According to the RFC7540 section 9.1.2 we MAY retry the request manually with a new TCP connection.
The iOS' Safari browser and all web browsers handled this correctly by retrying the request.
Isn't the webview also supposed to handle this automatically? @eskimo
Ever since I've updated to Xcode 15.2 (I'm currently using Xcode 15.3) my console gets flooded with logs from CFNetwork and DataDetectorsUI. I've never seen those logs before. Is there a way to suppress them? I can't even find my own logs anymore without filters.
CFNetwork
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> resuming, timeouts(25.0, 604800.0) QOS(0x15) Voucher (null)
[Telemetry]: Activity <nw_activity 12:2[78557FD1-54F3-4B77-8C5C-57F500D67286] (reporting strategy default)> on Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> was not selected for reporting
Connection 29: set is idle false
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> now using Connection 29
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> sent request, body S 535
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> received response, status 201 content U
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> done using Connection 29
Connection 29: set is idle true
HTTP/2 Connection 29 Stream 7 ended successfully true
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> request *** is NOT allowed to set HSTS for main doc (null)
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> response ended
Task <50C80E0E-9DA5-428F-A473-9D0228088022>.<4> finished successfully
Connection 19: cleaning up
Connection 19: done
Applying proxy auth: response=(null), proxyURL=(null), request=(null), credentials=(null), handle=0x11c2f7d30
Connection 21: cleaning up
Connection 23: cleaning up
Connection 22: cleaning up
DataDetectorsUI
operation 0x10ff7e560
operation 0x10ff7e560 is discarded
Calling the completion block for 0x10ff7e560
dispatchScanQueryCreationWithCompletionBlock of operation <DDTextKitOperation: 0x10ff7e560> completion block: success: 0
operation 0x10ff7e560
operation 0x10ff7e560
operation 0x10fb2f850
really creating scan query in operation 0x10fb2f850!
operation 0x10fb2f850