Rendering Exception on iOS using Gluon/JavaFXPorts - ios

After trying out some apps on iOS with Gluon I noticed some rendering bugs.
Firstly the JavaFX LineChart behaves incorrectly. The lines are displaced and the shadows don't show up correctly. I didn't examine this further but this might be related to the following problem.
The more important thing is that there is an exception while rendering the Gluon demo App called DoodleTrace. After painting the line (about 20cm long on the iPad) I get an exception in the rendering Thread:
(Note: iPad 3 running iOS 7)
Triggered once (after about 20 cm):
va.lang.IllegalArgumentException: Upload requires 1793077 elements, but only 1102848 elements remain in the buffer
at com.sun.prism.impl.BaseTexture.checkUpdateParams(BaseTexture.java)
at com.sun.prism.es2.ES2Texture.update(ES2Texture.java)
at com.sun.prism.impl.BaseContext.flushVertexBuffer(BaseContext.java)
at com.sun.prism.impl.ps.BaseShaderContext.setRenderTarget(BaseShaderContext.java)
at com.sun.prism.impl.BaseContext.setRenderTarget(BaseContext.java)
at com.sun.prism.impl.BaseGraphics.<init>(BaseGraphics.java)
at com.sun.prism.impl.ps.BaseShaderGraphics.<init>(BaseShaderGraphics.java)
at com.sun.prism.es2.ES2Graphics.<init>(ES2Graphics.java)
at com.sun.prism.es2.ES2Graphics.create(ES2Graphics.java)
at com.sun.prism.es2.ES2SwapChain.prepare(ES2SwapChain.java)
at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java)
at java.lang.Thread.run(Thread.java)
Outstanding resource locks detected:
ES2 Vram Pool: 3,457,040 used (0.6%), 91,324,416 target (17.0%), 536,870,912 max
7 total resources being managed
average resource age is 28.4 frames
0 resources at maximum supported age (0.0%)
3 resources marked permanent (42.9%)
1 resources have had mismatched locks (14.3%)
1 resources locked (14.3%)
6 resources contain interesting data (85.7%)
0 resources disappeared (0.0%)
Triggered on every touch event after the above exception occurred:
java.lang.IllegalArgumentException: Upload requires 1793077 elements, but only 1102848 elements remain in the buffer
at com.sun.prism.impl.BaseTexture.checkUpdateParams(BaseTexture.java)
at com.sun.prism.es2.ES2Texture.update(ES2Texture.java)
at com.sun.prism.impl.BaseContext.flushVertexBuffer(BaseContext.java)
at com.sun.prism.impl.ps.BaseShaderContext.setRenderTarget(BaseShaderContext.java)
at com.sun.prism.impl.BaseContext.setRenderTarget(BaseContext.java)
at com.sun.prism.impl.BaseGraphics.<init>(BaseGraphics.java)
at com.sun.prism.impl.ps.BaseShaderGraphics.<init>(BaseShaderGraphics.java)
at com.sun.prism.es2.ES2Graphics.<init>(ES2Graphics.java)
at com.sun.prism.es2.ES2Graphics.create(ES2Graphics.java)
at com.sun.prism.es2.ES2SwapChain.createGraphics(ES2SwapChain.java)
at com.sun.prism.es2.ES2SwapChain.createGraphics(ES2SwapChain.java)
at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java)
at java.lang.Thread.run(Thread.java)

Related

libfuzzer fuzzing harness crash not reproducible

I want to fuzz an existing harness from stbi harness and make a small change. From free(img) to if(img) free(img);
compile with this command clang -fsanitize=fuzzer,address -ggdb -O0 stbi_read_fuzzer.c -o fuzzer, and run with ./fuzzer corpus -fork=1 -ignore_crashes=1 -dict=jpeg.dict -seed=123
After few hours it produce some crash (global buffer overflow, heap use after free, buffer overflow). But when I run all crash file it didn't crash
aldo#vps:~/stb/tests$ ./fuzzer crash-edab9036233c269e258fe93c2a46d46d5d6e7112
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2279336272
INFO: Loaded 1 modules (2132 inline 8-bit counters): 2132 [0x61b510, 0x61bd64),
INFO: Loaded 1 PC tables (2132 PCs): 2132 [0x5d0258,0x5d8798),
./fuzzer: Running 1 inputs 1 time(s) each.
Running: crash-edab9036233c269e258fe93c2a46d46d5d6e7112
Executed crash-edab9036233c269e258fe93c2a46d46d5d6e7112 in 3 ms
***
*** NOTE: fuzzing was not performed, you have only
*** executed the target code on a fixed set of inputs.
***
Why it didn't crash?
I'm using ubuntu 20.04 with llvm12 from apt.llvm.org
Old question but I had a similar issue.
In my case I fuzzed a stateful API and forgot to reset the API at the beginning of LLVMFuzzerTestOneInput. So a previous invocation set the API in a invalid state but it didn't crash right away. Only on second invocation the API did crash.
So my guess would be that similarly in your harness some internal state / global variable was changed in a previous invocation. Try to reset everything.
This is because libFuzzer runs in-process and just calls the LLVMFuzzerTestOneInput function as often as possible. The program won't get re-initialized on its own. This is documented:
The fuzzing engine will execute the fuzz target many times with different inputs in the same process.
Ideally, it should not modify any global state (although that’s not strict).

Xcode 12 quit unexpectedly in Mac OS 10.15.4

Xcode 12 quit unexpectedly in Mac OS 10.15.4.
The document “Main.storyboard” had an issue that was found and repaired.
This may be due to an SCM operation such as merging. Please save the document to fix the issue.
Multiple resources have the same name: groupTableViewBackgroundColor.
Date/Time: 2020-09-26 08:18:54 +0530
End time: 2020-09-26 08:26:49 +0530
OS Version: Mac OS X 10.15.4 (Build 19E266)
Architecture: x86_64h
Report Version: 29
Data Source: Stackshots
Shared Cache: 0x2fb4000 01EE95E0-91B0-354A-BD0A-C761305CD75D
Command: Xcode
Path: /Applications/Xcode 12.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 12.0 (17219)
Build Version: 2
Product Build Version: 12A7209
Project Name: IDEFrameworks
Source Version: 17219000000000000
Parent: launchd [1]
PID: 2432
Event: hang
Duration: 475.00s
Duration Sampled: 1.99s (process was unresponsive for 473 seconds before sampling)
Steps: 20 (100ms sampling interval)
Hardware model: MacBookAir7,2
Active cpus: 4
Time Awake Since Boot: 5700s
Fan speed: 1234 rpm
--------------------------------------------------
Timeline format: stacks are sorted chronologically
Use -i and -heavy to re-report with count sorting
--------------------------------------------------
Heaviest stack for the main thread of the target process:
20 <truncated backtrace>
20 __psynch_mutexwait + 10 (libsystem_kernel.dylib + 12386) [0x7fff6a22a062]
*20 psynch_mtxcontinue + 0 (pthread + 9566) [0xffffff7f82d6e55e]
Process: Xcode [2432]
UUID: BEF84410-992D-3871-AD2A-C8C9AB4BD25C
Path: /Applications/Xcode 12.app/Contents/MacOS/Xcode
Architecture: x86_64
Parent: launchd [1]
UID: 501
Sudden Term: Tracked
Footprint: 490.54 MB
Start time: 2020-09-26 08:26:47 +0530
End time: 2020-09-26 08:26:48 +0530
Num samples: 20 (1-20)
CPU Time: 0.022s (52.9M cycles, 37.5M instructions, 1.41c/i)
Note: Unresponsive for 473 seconds before sampling
Note: 4 idle work queue threads omitted
I had exactly the same problem.
Good news, I found the solution!
Short story:
You need to find the Views that have tableCellGroupedBackgroundColor as their color and change it.
tip: This color was used by the tableView cells as a background color, look there first.
Long story:
After updating to Xcode 12.2 every time I opened Main.storyboard, the same message was displayed as yours.
Assuming it is a color incompatibility (tableCellGroupedBackgroundColor in our case), I opened Main.storyboard as Source Code (right click on the Main.storyboard -> Open As -> Source Code) and searched for "tableCellGroupedBackgroundColor".
I noticed that this color appeared several times in the "resources" at the end of the file, while it should appear only once.
This is probably why Xcode displays the error message.
Looking above, I noticed that the specific color was in the background color in tableView cells.
So I reopened Main.storyboard as Interface Builder (right click on the Main.storyboard -> Open As -> Interface builder-Storyboard) and changed the background color in all tableView cells to Default.
pro tip: You can delete the colors from the Source code directly, by deleting the lines that refers the colors to the Views.
That's it!
After that everything works perfectly again!
I have a similar issue with additional infos. In xCode 12, and 12.2 beta, my main storyboard appear after many minutes and I get:
The document “Main.storyboard” had 15 issues that were found and repaired.
The save popup also shows:
This may be due to an SCM operation such as merging. Please save the document to fix the issues.
The errors are of 3 types for me:
1- Multiple resources have the same name: darkTextColor.
2- Multiple resources have the same name: groupTableViewBackgroundColor.
3- Multiple resources have the same name: tableCellGroupedBackgroundColor.
It asks to save in order to repair but it does not repair at all.
There are no warning in the environment either before or after the save.
When the project finally loads, if I edit it for a while then it stops responding and I have to force xCode to quit. If I load my app in xCode 11.7 it shows instantly and work fine. If one of our users upgrades to IOS14 with the working version of the app it crashes in some views however if I compile with xCode12, even with storyboard file that I cannot open, and I publish on IOS14 the apps work well and the broken views shows up.
When I debug in xCode 12 and navigate to a broken view the app/xCode stops but no warning or error are displayed. I tried to change and remove this line in the storyboard file without success:

SlimDX stops loading big textures after a while

My app from time to time initializes a bunch of DirectX stuff and loads scenes, sometimes containing some large textures (up to 200–300 MB per texture). At first, everything works fine, but after a while FromMemory() just stops working, but only for big textures:
SlimDX.Direct3D11.Direct3D11Exception: E_FAIL: An undetermined error occurred (-2147467259)
at SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
at SlimDX.Direct3D11.ShaderResourceView.ConstructFromMemory(Device device, Byte[] memory, D3DX11_IMAGE_LOAD_INFO* loadInformation)
at SlimDX.Direct3D11.ShaderResourceView.FromMemory(Device device, Byte[] memory)
Of course, I dispose all previously loaded ShaderResourceViews loaded before loading a new scene. But FromMemory() starts working again only after app’s restart. Could you please tell me what else could be wrong?
UPD:
With Texture2D.FromMemory(), I get this:
System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at D3DX11CreateTextureFromMemory(ID3D11Device* , Void* , UInt32 , D3DX11_IMAGE_LOAD_INFO* , ID3DX11ThreadPump* , ID3D11Resource** , Int32* )
at SlimDX.Direct3D11.Resource.ConstructFromMemory(Device device, Byte[] memory, D3DX11_IMAGE_LOAD_INFO* info)
at SlimDX.Direct3D11.Texture2D.FromMemory(Device device, Byte[] memory)
And with native code debugging enabled:
Exception thrown at 0x748AA882 in app.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x00AFC7C8.
Exception thrown: 'System.Runtime.InteropServices.SEHException' in SlimDX.dll
Sadly, I have no idea how D3DX11CreateTextureFromMemory() actually works and why does it try to re-allocate memory. Maybe it’s time to move to x64…
Found the problem. Turns out all I had to do is to add “LARGEADDRESSAWARE” flag to executable. Without it, 1 GB was the limit — quite easily achievable with 300 MB per texture.
Also, of course, since most of that data ended up in Large Object Heap, GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce helped as well.
Sorry for wasting your time.

Xcode - is it possible to debug crashes in the Interface Builder's Live Rendering process (IBDesignable)?

Question
Is it possible to set breakpoints and debug code executed by Xcode / Interface Builder's Live Rendering? That is, I am using the IBDesignable and IBInspectable attributes to affect the view as it is rendered in an interface builder storyboard, and would like to be able to debug "IB crashed" errors. I don't recall this from the WWDC session, other than the section on prepareForInterfaceBuilder.
Context
I recently started seeing a number of errors reporting that IB crashed when attempting to render my code. I ultimately traced it to an otherwise innocent line of code in layoutSubviews in one of my views that was linked from the storyboard. The specific problem that IB - when rendering live views, called layoutSubviews before setting all the view's child view properties (which seems like a separate problem, in and of itself). This contrasted with the simulator and device, in which the views were set ahead of the first call to layoutSubviews. Long story short though, it involved diffing a bunch of files to find the offending change. Suffice to say, I could have found the problem quickly if it were possible to set breakpoints and trap the crash.
Has anyone figured out how to debug and/or generally trap these problems, or is that access not yet available?
I watched the WWDC video again (§411 #22:00 or so). You have to
edit a view in IB, and set its custom class to a class in your codebase
set breakpoints as desired in your custom class
select the view in IB, then select Editor -> "Debug Selected Views" (at bottom)
Oddly, in my tests today, it is creating my view via (initWith)Frame instead of (initWith)Coder. This causes subsequent constraint configuration logic to fail as the sub views have not been set (as they would had 'withCoder been called).
(tools note: Xcode 8.2, macOS Sierra)
I had a very different failure than yours: I had a crash in code that resulted in an IB error in Xcode:
error: IB Designables: Failed to update auto layout status: The agent crashed
To debug this on macOS Sierra, open Console.app, and open "User Reports" in the right sidebar. Find the "IBDesignablesCocoaTouch*" crashes, and select the applicable one. This gave me the code-level info I needed to diagnose it.
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Application Specific Information:
CoreSimulator 375.21 - Device: IBSimDeviceTypeiPad2x - Runtime: iOS 10.3 (14E8301) - DeviceType: IBSimDeviceTypeiPad2x
Thread 0 Crashed:
0 libswiftUIKit.dylib 0x000000021a2ddead _TToFE5UIKitCSo7UIImagecfT24imageLiteralResourceNameSS_S0_ + 205
1 libswiftUIKit.dylib 0x000000021a2ddcef _TFE5UIKitCSo7UIImageCfT24imageLiteralResourceNameSS_S0_ + 79
2 com.company.App 0x0000000216df74ad _TZFC10App21ControlsP33_F7118662B6663018C7DD0DEBB6FDD87511buttonImagefT8forStateOS_25State_CSo7UIImage + 109 (Controls.swift:121)
…
(In my case, Interface Builder was failing to load an image literal. I had to implement this workaround: xcode 6 IB_DESIGNABLE- not loading resources from bundle in Interface builder)

Cocos2d X .Spontaneous unload of resources

On loading scene I preload all resources like sprites, sounds, etc. But one of my test devices (HTC Desire, Android 2.2.2) unloads resources after loading, so when the game tries to play some sound or draw sprite, it freezes for a moment to load the resource again.
This problem appers only on HTC Desire, I didn't met this problem on my other devices (Samsung Galaxy Ace, Android 2.3.6 & Acer A100 tab, Android 4.0.3).
Can someone tell me why this happens? Thanks.
This is how I preload resources:
for (.....)
{
CCString* file = CCString::create(path.c_str());
if(file) {
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(file->getCString());
}
}
I've also tried like this, but it gives the save result:
for (.....)
{
CCString* file = CCString::create(path.c_str());
if(file) {
CCSpriteFrame* frame = new CCSpriteFrame();
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(frame, file->getCString());
frame->retain();
}
}
In both ways CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo() says that all textures are loaded:
01-29 15:18:36.111: D/cocos2d-x debug info(7579): cocos2d: CCTextureCache dumpDebugInfo: 53 textures, for 103840 KB (101.41 MB)
I also tried to reduce amount of preloaded textures to 31 (42.76 MB), but nothing changed.
P.S.: I repeat, this problem appers only on Desire with 2.2 Android OS ...
One possible explanation for this behavior is described here, under "avoid purging caches during memory warnings".
By default cocos2d (and I suppose cocos2d-x is no different) will purge all caches when a memory warning is received. This means you can preload assets as much as you want, there need only be one memory warning and all of the preloaded (and currently unused) textures will be unloaded.

Resources