Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
How to reset WKWebView when it gets into a bad state without reloading the program

I have a hybrid web-app that uses Objective C and Javascript.
The javascript code triggers a call to wkwebkit on iOS which extracts a zip file entry (image) using the package ZipZap.
The image data in the zip file is represented as a blob, and then renderred on the screen.

The code to extract a zip file entry into a blob (binary -> base64 ascii -> binary -> blob) uses the following steps:

  • The entry is extracted as Objective C NSData type, and then encoded via base64, from binary into ASCII string.
  • The encoded base64 ASCII string is then decoded into a decoded binary string using the function atob().
  • The decoded binary string is then represented as Uint8Array in a byteArray.
  • Finally the Uint8Array byteArray creates a new Blob.

The reason that I'm using the base64 conversion, is to create a string that could be sent from Objective C to the javascript.

The code runs in a loop on the list of zip entries.
It runs ok on the entries in the list but at some point I get an error message from atob(): "invalid character for base64".
At this state, the value of the encoded base64 ASCII string shows "(null)".
From this point all the zip file entries return the same error and the encoded base64 ASCII string shows "(null)".
Then, the only way to recover is to reload the program which reinitiallizes WKWebView.

When I run a pure version of the web-app on an iOS device (i.g. not hybrid, via the browser, e.g. safari) the program also fails after a while with similar error (the blob buffer shows "null"), so I don't think this is a problem on iOS Objective C code side.

For reference, the program runs ok on other OSs, e.g. hybrid app on Android, pure web-app on Android/Linux/Windows/Mac in the browser.

From this, I suspect that WebView on iOS gets into bad state.

Ideally I want to solve the problem so that it does not occur in the first place.
So far I have not found how to do that so I'm looking for a way to recover without having to reload the program.
Is there a way to reset WKWebView without having to reload the program?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!