惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cloudbric
Cloudbric
T
The Blog of Author Tim Ferriss
美团技术团队
S
SegmentFault 最新的问题
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
P
Privacy & Cybersecurity Law Blog
N
News and Events Feed by Topic
爱范儿
爱范儿
T
Threatpost
The Cloudflare Blog
Spread Privacy
Spread Privacy
Latest news
Latest news
Last Week in AI
Last Week in AI
V
Vulnerabilities – Threatpost
Hugging Face - Blog
Hugging Face - Blog
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Project Zero
Project Zero
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
Tenable Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
阮一峰的网络日志
阮一峰的网络日志
C
Cyber Attacks, Cyber Crime and Cyber Security
量子位
I
Intezer
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - 【当耐特】
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
Netflix TechBlog - Medium
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK How Subject scaled 5× with Nutrient’s PDF SDK without rebuilding its document layer I replaced our sales training with an AI coach that runs in Slack — here’s what broke Redirecting to: https://securitybuzz.com/cybersecurity-news/why-enterprise-permissions-are-ais-most-dangerous-inheritance/ Nutrient .NET SDK vs. iText Core: Complete comparison for .NET developers DocuVieware: Support’s most frequently asked setup questions Introducing Nutrient Workflow How to convert PDF to Word in C# (.NET) When email and spreadsheets stop working: Work order approval workflows for field teams on the move Compliance with confidence: Why document-centric automation is the foundation of your mission Nutrient expands AI Assistant, automating multistep document workflows inside any application What is document generation? A developer’s guide to PDF generation Document Converter data flow and how real-time watermarks skip the queue PDF/UA compliance guide: Requirements, standards, and best practices Computers still can’t understand you How Athena Intelligence built AI agents for regulated enterprises with Nutrient’s document infrastructure How to convert HTML to PDF (2026): 4 methods from browser print to SDK How to build a document extraction pipeline with Nutrient Vision API OCR vs. intelligent document processing: Choosing the right document extraction engine Beyond OCR: How document intelligence eliminates manual processing in regulated industries Nutrient vs. IronPDF: Complete comparison for .NET developers Nutrient vs. Aspose.PDF: Complete comparison for .NET developers Redirecting to: https://fortune.com/2026/02/19/openclaw-who-is-peter-steinberger-openai-sam-altman-anthropic-moltbook/ Lufthansa Systems uses Nutrient to deliver reliable, scalable PDF rendering for pilots worldwide Nutrient vs. Syncfusion: Complete comparison for .NET developers React’s useTransition: The hook you’re probably using wrong First City Monument Bank streamlines banking processes with Nutrient Workflow Redirecting to: https://www.sdcexec.com/warehousing/automation/article/22957364/nutrient-workflow-automation-the-missing-link-in-supply-chain-efficiency The complete guide to digital signatures: PAdES, CAdES, and XAdES explained Nutrient Python SDK: Production-grade document processing for Python Introducing agentic document editing for web applications with AI Assistant Nutrient vs. QuestPDF: Complete comparison for .NET developers How we fixed the GdPicture license expiration (and what to do if you’re affected) Red team security testing with agentic AI The future of healthcare document automation Best healthcare workflow software compared Nutrient SDK product updates for Q4 2025 How Harvey scaled legal document workflows 50 percent MoM without rebuilding infrastructure HIPAA-compliant document management in hospitals How we optimized rendering performance while handling thousands of annotations in React — Part 2 Automated PII removal with Nutrient API Redirecting to: https://www.devopsdigest.com/2026-low-code-no-code-predictions Redirecting to: https://www.kmworld.com/Articles/Editorial/ViewPoints/Leaders-predict-AI-to-continue-permeating-all-aspects-of-KM-in-2026-172594.aspx What are deep agents and how do they solve complex problems? Whipping up document magic: Your easy-bake recipe for Vue and Nutrient Web SDK 🧁 What I’ve learned about product iteration planning while building SDKs Passwordless document signing: Three-layer security guide New zip folder functionality streamlines file management in Document Automation Server The keyboard shortcuts playbook: Taking control of keyboard events in Nutrient Web SDK From experienced engineer to AI beginner: My unexpected journey AI-assisted manual testing: Handling Safari’s PDF rendering and UI quirks How to keep a 20-year-old SDK up to date How we optimized rendering performance while handling thousands of annotations in React — Part 1 Nutrient announces new executive hires to accelerate next phase of growth High performance UI using web workers Automate document conversion at scale with Python and Nutrient DCS From curiosity to PLG (and AI): My journey to understanding product-led growth Prost to progress: One year as Nutrient Pigeon usage at Nutrient: Bridging native SDKs to Flutter Modernizing CI build servers: How to migrate from Chef to Ansible Unix man pages: AI-friendly documentation since 1971 Consistent hashing for even load distribution Best AI redaction APIs: Complete comparison guide for 2025 Why AI document redaction matters for modern security From coding to coordinating: How AI transformed my workflow What is intelligent document processing (IDP)? A complete guide Enterprise PDF SDKs: Best PSPDFKit (now Nutrient) alternatives Nutrient SDK product updates for Q3 2025 GdPicture support best practices Redacting sensitive data with Nutrient AI redaction API How AI is transforming the customer experience at Nutrient: From instant answers to intelligent support
Debugging in iOS: Resolving UITextView flickering issues
Egor Mikhnevich · 2023-12-17 · via Inside Nutrient

After joining PSPDFKit, I was lucky enough to dive into a bunch of debugging sessions. However, only some were successful, and of those, most were backed by the same principles. So in this post, I’ll attempt to outline said principles, which will come in handy the next time I need to debug something. Along the way, I’ll share the story of how I solved a particular issue: UITextView flickering.

Frustrating smile

Early on in my career, I wanted to become a game developer. In my opinion, game development has some of the most hilarious bugs across all software industries. For example:

Alas, iOS apps are usually prone to standard problems that aren’t so amusing, such as non-responsive user interfaces (UIs), stale data, and, of course, neverending crashes. They’re extremely annoying for both users and developers, and rarely are they amusing,

However, recently, I encountered something unexpected — something that got a frustrated smile and an “Oh, wow!” exclamation from me. Here’s a video of the unexpected behavior in action. In the video, the caret jumps all over a text field without a user’s participation.

Of course, there’s nothing funny about this for our customer. But now that the fix is out (12.2.0), it’s a good time to collect my thoughts and share the debug chronology of this out-of-line issue.

Setting the stage

Before jumping in to the debug techniques, one might ask: “What on earth text fields are even doing in PDFs?” Well, that’s an excellent question! Before joining PSPDFKit, I’d imagined PDFs as images and texts. And, for the most part, they are images and text. However, there are other parts that do totally wild things. For example, PDFs can carry all kinds of annotations, audio, and even video. 🤯

Returning to text fields, they’re part of PDFs referred to as forms. Forms in PDFs are somewhat similar to web forms (you know, name/email/password fields). Thus, from a user’s perspective, forms are rather straightforward. The implementation, on the other hand, is packed with intricate logic. Forms might interoperate with JavaScript, they might affect document representation (for example, hiding or showing certain parts of it), and much more.

If you to know more about forms and how to use them, refer to our introduction to forms guide.

Text view and forms

In general, forms are built from a predefined set of controls, like text fields and checkboxes. The same set of controls is also available on iOS. Alas, most native controls require some finishing touches before they can function in a PDF forms context.

UITextView is a prominent example of a native iOS control that requires many finishing touches, specifically when it comes to its relationship to UIScrollView. The following is an example of some things that require careful consideration:

The list goes on and on. We tend to stumble on new edge cases even after 10 years of fusing UITextView with UIScrollView.

Starting out

Debugging sessions are reminiscent of a gradient descent, in that the goal is to narrow a problem’s scope with every step. Each step usually involves the following phases: research, formulating a hypotheses, rejecting or proving the hypotheses, and planning next steps with new information.

Before starting out debugging, I tried to reliably reproduce the problem and outline the reproduction steps. In this case, the customer who reported this issue kindly provided a video with reproduction steps and a sample document that reproduced the problem. That’s a welcome shortcut and outrageous cheating, but I’ll take it.

Ideally, one would reproduce the problem in a regression test. I didn’t, and I regret it now, because it would’ve saved so much time.

Next, I began gathering as much information as possible about the problem at hand by asking myself a series of questions, including:

  • What views are onscreen when the problem surfaces?
  • Can it be reproduced in the iOS simulator?
  • Is it a regression?
  • Does the bug happen only on specific set of devices?

Having a predefined list of icebreaker questions streamlines this part. It also provides hints about possible information sources. Maybe you have remote logging, maybe your crashes have breadcrumbs, etc.

It also helps to write down the answers.

Debug journals

I have to confess, I used to hate debugging. It takes time, it takes lots and lots of effort, and you might run into Apple frameworks that are close sourced. Combine thee points, and it doesn’t sound particularly inspiring. I also used to think that it’s a one-shot process; it’s like a game without saves, and you either find a bug’s cause, or you die and start anew. A bug’s context erases from memory with time.

This is where debug journals come into play. For me, keeping notes while debugging is crucial. Yes, journals doesn’t magically solve everything, and debugging still requires lots of work, but now, at least there are checkpoints.

So, the way I debug is by asking and answering questions in a journal, which, for me, is a plain text file. Here’s an example from the flickering cursor issue:

Document flickering when zoomed in on text field entry · #36018 (keeping the issue’s number as a search reference)

- [x] Does it reproduce on iOS 14?

- Yes.

- [x] Does it reproduce on iOS 15?

- Yes.

- [x] Can it be reproduced in `FormTests.pdf`?

- Ah, nope. The next idea is to extract that specific form to a new document.

- Forms are like annotations, so I can probably grab a single element and add it to a freshly created document. 🤔

- [x] Can it be due to a view hierarchy difference?

...

- [x] Can it be connected to the text view’s font?

- Nope, the default font also causes bouncing.

And so on…

I usually end up with a long list of questions and answers I sift through. They help me quickly form and validate my next hypothesis. And, because I have all the notes, I can always leave a problem for later without losing my progress.

Diving in

Okay, getting back on track. After loading a sample document and checking Xcode’s Debug View Hierarchy tool, it became apparent that the problem was somehow related to scroll views — specifically, one of our private UIScrollView subclasses. So I made some notes in the journal:

- It’s somehow related to `PSPDFAvoidingScrollView`.

- Does any class’s logic affect the scroll offset?

...

I stumbled upon the overridden -[PSPDFAvoidingScrollView setContentOffset:animated:] method, along with a bunch of methods that affected scroll offsets. I then commented them out or replaced them with no-op actions. The problem persisted. So, I concluded that it’s not something in PSPDFAvoidingScrollView, but rather in other classes that use it:

- It’s somehow related to `PSPDFAvoidingScrollView`.

...

- The problem still reproduces even after commenting out everything from `PSPDFAvoidingScrollView`.

- Does it have anything to do with clients of `PSPDFAvoidingScrollView`?

There were at least three places that popped up in setContentOffset stack traces. I went through them one by one, noting them down, commenting them out, and checking whether the problem reproduced. The journey wasn’t that smooth, and initially I stumbled down a wrong path, but I’ll spare you the boring parts.

Eventually, I determined that one of the callers of setContentOffset propagated suspicious values to the scroll view:

- `PSPDFTextView` somehow influences the `PSPDFAvoidingScrollView` offset.

- `-[PSPDFAvoidingScrollView setContentOffset:animated:]` gets a legit frame and the next one is scrambled up:

- That’s the correct origin (x = 1405.5643702027589, y = 1019)

- That’s the scrambled origin (x = 136.00433972557607, y = 1019)

- It causes bouncing.

In the first call, the x origin was 1405, but in the second call, it was 136. This is a big difference. So somewhere when setting the content offset, the x origin value was incorrectly calculated, leading to the bouncing. This value came from another private class, PSPDFTextView. I was slowly circling in on the problem.

After replacing PSPDFTextView with a plain UITextView, the problem… didn’t go away. 😬 I’d ended up with a plain UITextView that was passing fancy offsets to a plain UIScrollView. There was only UIKit in stack traces. It surely sounds suspicious. It’s almost like blaming a compiler for errors. So, I summarized the findings, and then I cried out for help.

Pairing up

Like everything, pair programming has its own pros and cons. However, when it comes to debugging, I find it hard to pinpoint the right moment to pair up with someone. On one hand, together there’s a chance of resolving problems more quickly. Alas, debugging is usually time consuming, so, pairing up means spending twice as much time on something.

At this point, though, I realized I wouldn’t mind another pair of eyes on the code. If my conclusion were true, we would’ve needed to look into UIKit internals, which means disassembling UIKit. I’m far from an expert when it comes to disassembling and spelunking. Thankfully, my team is quite well versed in it. Long story short, Douglas (my team manager) and I jumped on a call to make sense of my findings.

It took literally two questions and a quick glance at a method from the stack trace, -[UITextView _scrollRect:toVisibleInContainingScrollView:], to figure out what was going on.

Our findings

The gist is that, for some reason, UITextView tries to adjust the visible area of its parent scroll view: UITextView tries to highjack its parent, UIScrollView.contentOffset, given certain conditions. It works fine until a parent scroll view is zoomed.

The behavior is caused by textView.scrollEnabled = false. With disabled scrolling, -[UITextView _scrollRect:toVisibleInContainingScrollView:] starts adjusting the parent scroll view.

Remember PDF forms? Their elements also have setting flags. One of them is 🥁 doNotScroll 🥁. doNotScroll can be set on text form fields, determining whether text in a form field can be scrolled or if it should stay fixed. If this flag is set, we propagate this to the UITextView. That’s where textView.isScrollEnabled was getting its value from.

Solution

If your app has an editable UITextView embedded in a UIScrollView, make sure that the text view’s scrolling is always enabled, e.g. textView.scrollEnabled = true.

If you need to prevent scrolling in text views contained in scroll views, set text views’ frames to match their content programmatically — for example, by calling NSAttributedString.boundingRect(with:options:attributes:context:) and updating a text view’s frame accordingly.

We also added a regression test. It’s a UI test that zooms into a text field with disabled scrolling, enters a text, and observes for UITextSelectionDidScroll notifications. This internal UIKit notification is fired whenever UITextView tries to adjust its parent’s content offset.

Conclusion

In general, before you dive into a problem, try to come up with clear reproduction steps. Chisel away at the part in question and see whether the problem still reproduces. Ideally, you should end up with a minimal reproduction example. It can even be a standalone Xcode project or a Swift Playground.

Additionally, consider keeping a debug journal! It’s a place for internal conversation. What’s more is it helps to preserve and share knowledge. Imagine instead of saying, “Yeeeah, I’m still working on the bug,” you can provide a decent report with your ongoing progress.

Don’t be afraid to ask for help. It might be someone from your team, it might be the future you (take a break for a day), or it might be a rubber duck. Sum up current findings to clarify the situation.

You can find more debugging tips in The Pocket Guide to Debugging(opens in a new tab) by the amazing Julia Evans(opens in a new tab).