Supplying null as a callback to WKWebsiteDataStore.getDefaultDataStore.removeData causes crash
Issue details
Calling WKWebsiteDataStore.getDefaultDataStore().removeData and passing 'null' as the Runnable callback will cause a crash.
Usually when a Runnable is used as a callback handler, one can just pass in null, and it will work fine.
Workaround is simple, just supply an empty lambda.
Reproduction steps/code
WKWebsiteDataStore.getDefaultDataStore().removeData(WKWebsiteDataStore.getAllWebsiteDataTypes(), NSDate.getDistantPast(), null);
Configuration
Build Tools:
- [x] IDEA plugin
- [ ] Eclipse plugin
- [ ] Gradle plugin
Versions:
- Robovm: 2.3.22
- XCode: 15.4
- JDK: OpenJDK 17
Build Targets:
This is tested on an M1, with the iPhone 15 Simulator, (running iOS 17.5)
@klianc09 its a bit late reply, but anyway. its not RoboVM's bug. if you check the crash log -- you will find that it craashes inside WebKit.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
Exception Codes: 0x0000000000000001, 0x0000000000000010
VM Region Info: 0x10 is not in any region. Bytes before following region: 4334370800
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 102594000-103cf8000 [ 23.4M] r-x/r-x SM=COW /Users/USER/Library/Developer/CoreSimulator/Devices/0FB39DD3-660C-4E06-8368-555824A9F53C/data/Containers/Bundle/Application/5546C1ED-93E8-45AE-A2F0-A31B472E5A22/IOSLauncher.app/IOSLauncher
Triggered by Thread: 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 WebKit 0x18d8ffb10 WTF::Detail::CallableWrapper<-[WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:]::$_137, void>::call() + 4
1 WebKit 0x18dea0824 WTF::Detail::CallableWrapper<WebKit::WebsiteDataStore::removeData(WTF::OptionSet<WebKit::WebsiteDataType>, WTF::WallTime, WTF::Function<void ()>&&)::$_0, void>::call() + 132
2 WebKit 0x18d6f3fc8 WTF::CallbackAggregatorOnThread<(WTF::DestructionThread)2>::~CallbackAggregatorOnThread() + 48
3 WebKit 0x18d6f3f8c WTF::Detail::CallableWrapper<WTF::ThreadSafeRefCounted<WTF::CallbackAggregatorOnThread<(WTF::DestructionThread)2>, (WTF::DestructionThread)2>::deref() const::'lambda'(), void>::call() + 20
4 WebKit 0x18d6f3f30 WTF::ThreadSafeRefCounted<WTF::CallbackAggregatorOnThread<(WTF::DestructionThread)2>, (WTF::DestructionThread)2>::deref() const + 88
5 WebKit 0x18dea09e8 WTF::Detail::C
also if you try same code in Xcode/ObjC project, it will crash as well.
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
modifiedSince: [NSDate distantPast]
completionHandler:nil];
more over, xcode will warn with message Null passed to a callee that requires a non-null argument.
In other words null is just not allowed there by the API